我该如何解决错误"通过安全透明的方法尝试“System.Web.Http.GlobalConfiguration.get_Configuration() [英] How do I resolve the error "Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()

查看:4608
本文介绍了我该如何解决错误"通过安全透明的方法尝试“System.Web.Http.GlobalConfiguration.get_Configuration()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了两个项目的解决方案:一个MVC 4和类库。该解决方案编译并运行良好。然后我安装包'Microsoft.AspNet.WebApi.OData - pre中的OData的WebAPI的功能来拉。当我这样做,我得到以下运行时错误:

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:

尝试通过安全透明的方法'System.Web.Http.GlobalConfiguration.get_Configuration()来访问安全关键型System.Web.Http.HttpConfiguration失败。

Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.

在WebApiConfig.Register(GlobalConfiguration.Configuration)运行在Global.asax中

When WebApiConfig.Register(GlobalConfiguration.Configuration) runs in Global.asax

在我这样做,卸载包似乎并没有解决。显然,它消除了OData的组件,但随后离开任何组件导致此。与-RemoveDependencies删除删除库中的所有的WebAPI引用,我无法拿回来处于工作状态。

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.

什么包到底我在,我怎么能在香草MVC4应用程序启用的WebAPI的OData?

What package hell am I in and how can I enable WebApi OData in a vanilla MVC4 app?

推荐答案

如果您创建的模板一个MVC 4应用程序,那么你就安装Web API 4.0。如果你使用

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

您将依赖的ASP.NET Web API 5.0 RC。

You will be dependent on ASP.NET Web API 5.0 rc.

我的建议是使用空ASP.NET Web应用程序的模板,而不是MVC 4.0模板。

My suggestion is to use "Empty ASP.NET web application" template rather than MVC 4.0 template.

这篇关于我该如何解决错误"通过安全透明的方法尝试“System.Web.Http.GlobalConfiguration.get_Configuration()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆