I have created a solution with two projects: A MVC 4 and a Class Library. The solution compiles and runs fine. I then install-package 'Microsoft.AspNet.WebApi.OData -pre to pull in OData WebApi functionality. When I do, I get the following error at runtime:
Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.
When WebApiConfig.Register(GlobalConfiguration.Configuration) runs in Global.asax
Once I do, uninstalling the package doesn't seem to fix. It removes the OData components obviously, but then leaves whatever assembly is causing this. removing with -RemoveDependencies removes ALL WebApi references in the library, and I'm unable to get it back in a working state.
What package hell am I in and how can I enable WebApi OData in a vanilla MVC4 app?
It's a mismatch on the assemblies for the given version of WebAPI. Mine was failing because I was referencing a mismatched version of System.Web.Http.WebHost
. So you can...
Install the latest WebAPI from NuGet
-OR-
Make sure all your Microsoft.AspNet.WebApi.*
packages are on the same version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With