Skip to content

Commit 5ff3ae9

Browse files
committed
Add MissingMethodException'
1 parent 5cb06bb commit 5ff3ae9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@ public virtual IServiceProvider BuildContainer()
8787
{
8888
return services.BuildServiceProvider();
8989
}
90-
catch
90+
catch (MissingMethodException)
9191
{
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
96+
*/
97+
9298
MethodInfo buildServiceProviderMethod =
9399
typeof(ServiceCollectionContainerBuilderExtensions)
94100
.GetMethod(nameof(ServiceCollectionContainerBuilderExtensions.BuildServiceProvider), new[] { typeof(IServiceCollection) });

0 commit comments

Comments
 (0)