How do I resolve the error "Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()
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
I ran "update-package Microsoft.AspNet.WebApi" in the Package Manager Console in VS and worked like a charm.
If you create an MVC 4 app from its template, then you are installing Web API 4.0. if you use
install-package 'Microsoft.AspNet.WebApi.OData -pre
You will be dependent on ASP.NET Web API 5.0 rc.
My suggestion is to use "Empty ASP.NET web application" template rather than MVC 4.0 template.