Getting the TypeLoadException when using some of the registration extension methods.
builder.RegisterModelBinders(Assembly);
builder.RegisterModelBinderProvider();
builder.RegisterFilterProvider();
The following respective exceptions are thrown, however builder.RegisterControllers(Assembly)
works fine.
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)
Here are what the relevant packages packages.config look like:
<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" />
If it's any consolation, the previous Autofac.Mvc5
package was throwing the same error.
These are the binding redirects for 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>
I rebuilt the test project's .csproj and the test passes now, I have not isolated the exact issue. If I find it, I will post it here.