I recently upgraded to ASP.Net MVC 5 and upon upgrading my code no longer runs.
I'm performing plugin loading via reflecting on types in my current AppDomain.
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
IEnumerable<Type> types = assemblies.SelectMany(o => o.GetTypes()).ToList(); // <-- Throws error
I'm getting the error on the Microsoft.Web.Mvc assembly:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
and upon retrieving the loader exceptions I get the following:
- [0] {System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Web.Mvc.CreditCardAttribute.GetClientValidationRules(System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.} System.Exception {System.TypeLoadException}
- [1] {System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Web.Mvc.EmailAddressAttribute.GetClientValidationRules(System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.} System.Exception {System.TypeLoadException}
- [2] {System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Web.Mvc.FileExtensionsAttribute.GetClientValidationRules(System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.} System.Exception {System.TypeLoadException}
- [3] {System.TypeLoadException: Inheritance security rules violated by type: 'Microsoft.Web.Mvc.CookieValueProviderFactory'. Derived types must either match the security accessibility of the base type or be less accessible.} System.Exception {System.TypeLoadException}
- Etc...
I know the MVC team removed the AllowPartialTrustedCallers
assembly attribute. This is a breaking change http://www.asp.net/visual-studio/overview/2013/release-notes#knownissues . My web.config is set to full trust, but still no-go.
Any ideas??