asp.net-mvc-4 – WebAPI OData 5.0 Beta – 访问GlobalConfiguratio
|
我最近安装了WebApi OData 5.0框架的预发布版本,以便使用新的$expand支持.一切都建好了,但是我在App_Start上得到了一个奇怪的例外. Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed. 源错误: Line 12: protected void Application_Start()
Line 13: {
Line 14: WebApiConfig.Register(GlobalConfiguration.Configuration); // <--
Line 15: }
堆栈跟踪: [TypeAccessException: Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.Http.GlobalConfiguration.get_Configuration() +0 API.WebApiApplication.Application_Start() in Global.asax.cs:14 [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,HttpApplication app) +12863325 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo[] handlers) +175 System.Web.HttpApplication.InitSpecial(HttpApplicationState state,MethodInfo[] handlers,IntPtr appContext,HttpContext context) +304 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext context) +404 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475 [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +12721257 Google显示的很少. 解决方法在包管理器控制台中按照给定的顺序运行以下命令:Uninstall-Package Microsoft.AspNet.Mvc.FixedDisplayModes Update-Package Microsoft.AspNet.Mvc -Pre Update-Package Microsoft.AspNet.WebApi -Pre Update-Package Microsoft.AspNet.WebApi.Tracing 现在,对web.config应用以下更改: >在项目的Web.config中,将应用设置网页值更新为3.0.0.0 <运行时间> < AssemblyBinding xmlns =“urn:schemas-microsoft-com:asm.v1”> < dependentAssembly> < assemblyIdentity name =“System.Web.Helpers”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-3.0.0.0”newVersion =“3.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.Mvc”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.WebPages”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-3.0.0.0”newVersion =“3.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“EntityFramework”publicKeyToken =“b77a5c561934e089”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“WebGrease”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“0.0.0.0-1.3.0.0”newVersion =“1.3.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.Http”publicKeyToken =“31bf3856ad364e35”culture =“neutral”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Net.Http.Formatting”publicKeyToken =“31bf3856ad364e35”culture =“neutral”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < / assemblyBinding> < /运行> 从Views文件夹打开web.config.这里有三件事要更新: >在configSections下,将Razor程序集的版本更新为3.0.0.0. 如果您安装了Web API帮助页面,请检查以上装配体的配置. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 在代码GZipping中的IIS压缩?
- asp.net-mvc-3 – 如何有效地从自相关表中加载数据
- asp.net – 如何在运行时更改页面位置
- asp.net-mvc-3 – 在Asp.net MVC中为optgroup功能使用Helpe
- ASP.NET和底层连接已关闭:无法为SSL / TLS安全通道建立信任
- ASP.NET MVC 2加载部分视图使用jQuery – 没有客户端验证
- asp.net-mvc – ASP.NET成员资格替代方案
- asp.net-mvc – 如何从对象HtmlAttributes中获取值
- asp.net-mvc – WebForms和MVC可以存在于一个项目中吗?
- asp.net – 用于Web应用程序的实体框架过度杀毒?
