一部の登録拡張メソッドを使用すると、TypeLoadException が発生します。
builder.RegisterModelBinders(Assembly);
builder.RegisterModelBinderProvider();
builder.RegisterFilterProvider();
次のそれぞれの例外がスローされますが、正常にbuilder.RegisterControllers(Assembly)
動作します。
TypeLoadException: Inheritance security rules violated while overriding member: 'Autofac.Integration.Mvc.AutofacModelBinderProvider.GetBinder(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
at Autofac.Integration.Mvc.RegistrationExtensions.RegisterModelBinders(ContainerBuilder builder, Assembly[] modelBinderAssemblies)
TypeLoadException: Inheritance security rules violated while overriding member: 'Autofac.Integration.Mvc.AutofacModelBinderProvider.GetBinder(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
at Autofac.Integration.Mvc.RegistrationExtensions.RegisterModelBinderProvider(ContainerBuilder builder)
TypeLoadException: Inheritance security rules violated by type: 'Autofac.Integration.Mvc.AutofacFilterProvider'. Derived types must either match the security accessibility of the base type or be less accessible.
at Autofac.Integration.Mvc.RegistrationExtensions.RegisterFilterProvider(ContainerBuilder builder)
関連するパッケージ packages.config は次のようになります。
<package id="Autofac" version="3.3.0" targetFramework="net45" />
<package id="Autofac.Mvc5" version="3.2.0" targetFramework="net45" />
<package id="Autofac.Wcf" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.1.0" targetFramework="net45" />
慰めになる場合は、以前のAutofac.Mvc5
パッケージが同じエラーをスローしていました。
Autofac のバインディング リダイレクトは次のとおりです。
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>