Skip to content

Commit

Permalink
Add MissingMethodException'
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Jun 3, 2022
1 parent 5cb06bb commit 5ff3ae9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Microsoft.AspNet.OData.Shared/DefaultContainerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ public virtual IServiceProvider BuildContainer()
{
return services.BuildServiceProvider();
}
catch
catch (MissingMethodException)
{
/* "services.BuildServiceProvider()" returns IServiceProvider in Microsoft.Extensions.DependencyInjection 1.0 and ServiceProvider in Microsoft.Extensions.DependencyInjection 2.0
* * (This is a breaking change)[https://github.com/aspnet/DependencyInjection/issues/550].
* To support both versions with the same code base in OData/WebAPI we decided to call that extension method using reflection.
* More info at https://github.com/OData/WebApi/pull/1082
*/

MethodInfo buildServiceProviderMethod =
typeof(ServiceCollectionContainerBuilderExtensions)
.GetMethod(nameof(ServiceCollectionContainerBuilderExtensions.BuildServiceProvider), new[] { typeof(IServiceCollection) });
Expand Down

0 comments on commit 5ff3ae9

Please sign in to comment.