You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -85,16 +85,13 @@ public virtual IServiceProvider BuildContainer()
85
85
{
86
86
try
87
87
{
88
-
returnservices.BuildServiceProvider();
88
+
// On .NET Framework platform, if using Microsoft.Extensions.DependencyInjection > 6.x version,
89
+
// The runtime throws exception directly when calling BuildContainer if we call 'services.BuildServiceProvider()' within it.
90
+
// So, wrap 'services.BuildServiceProvider()' into a private method call, we can catch the runtime exception directly
91
+
returnBuildServiceProviderImpl();
89
92
}
90
-
catch(MissingMethodException)
93
+
catch
91
94
{
92
-
/* "services.BuildServiceProvider()" returns IServiceProvider in Microsoft.Extensions.DependencyInjection 1.0 and ServiceProvider in Microsoft.Extensions.DependencyInjection 2.0
93
-
* * (This is a breaking change)[https://github.com/aspnet/DependencyInjection/issues/550].
94
-
* To support both versions with the same code base in OData/WebAPI we decided to call that extension method using reflection.
95
-
* More info at https://github.com/OData/WebApi/pull/1082
0 commit comments