简体   繁体   English

安全透明方法'WebMatrix.WebData.PreApplicationStartCode.Start()'尝试

[英]Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()'

Update: same for mvc 4 to mvc 5. 更新:mvc 4与mvc 5相同。

I started a new mvc 4 project and migrated an mvc 3 project in it (controllers/models/scripts etc). 我开始了一个新的mvc 4项目,并在其中迁移了一个mvc 3项目(控制器/模型/脚本等)。 While everything compiles now i get the following error: 虽然现在一切都编译我得到以下错误:

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed. 尝试通过安全透明方法'WebMatrix.WebData.PreApplicationStartCode.Start()'来访问安全关键方法'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)'失败。

I can't find anything on the web with this error. 我在网上找不到任何有关此错误的内容。 The error hits before getting into the application start. 在进入应用程序启动之前错误命中。

I tried reinstalling all assemblies with nuget, putting a 'clean' web.config to no avail. 我尝试用nuget重新安装所有程序集,将“干净”的web.config无效。

Anyone had this problem before? 以前有人有这个问题吗?

对我来说这个错误是因为我从MVC 4更新到MVC 5之后没有安装Microsoft.AspNet.WebHelpers。它是通过安装NuGet包修复的

Install-Package -Id  Microsoft.AspNet.WebHelpers

If you are getting the error 如果您收到错误

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed. 尝试通过安全透明方法'WebMatrix.WebData.PreApplicationStartCode.Start()'来访问安全关键方法'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)'失败。

In order to fix this install this package using NuGet package manager. 为了使用NuGet包管理器修复此安装此包。

Install-Package Microsoft.AspNet.WebHelpers

After that , probably you will get another error 在那之后,可能你会得到另一个错误

Cannot load WebMatrix.Data version 3.0.0.0 assembly 无法加载WebMatrix.Data版本3.0.0.0程序集

to fix this install this package using NuGet package manager. 使用NuGet包管理器修复此安装此包。

Install-Package Microsoft.AspNet.WebPages.Data

For anyone landing here who is trying to upgrade from MVC 4 to MVC5, I was able to resolve this issue by following the instructions at http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 . 对于那些试图从MVC 4升级到MVC5的人来说,我可以按照http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade上的说明解决这个问题。 -an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

I also had to install the "Microsoft.AspNet.WebApi.WebHost" package from nuget. 我还必须从nuget安装“Microsoft.AspNet.WebApi.WebHost”软件包。 But that's it. 但就是这样。

Oh, and I had to create this appSetting: <add key="owin:AutomaticAppStartup" value="false" /> 哦,我必须创建这个appSetting: <add key="owin:AutomaticAppStartup" value="false" />

:) :)

I tried all of the above solutions and it still wouldn't work, until I found that the web.config compilation element was referencing version 2.0.0.0 of WebMatrix.Data and WebMatrix.WebData. 我尝试了上述所有解决方案,但在我发现web.config编译元素引用了WebMatrix.Data和WebMatrix.WebData的2.0.0.0版之前,它仍然无效。 Changing the version of those entries in the web.config to 3.0.0.0 helped me. 将web.config中这些条目的版本更改为3.0.0.0对我有所帮助。

I've been struggling with a similar issue when upgrading mvc 4 to mvc 5 : mvc 4升级到mvc 5时,我一直在努力解决类似的问题:

Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed. 尝试通过安全透明方法'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()'来访问安全关键方法'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,System.String)'失败。

The delete extra files check box in the publish dialog solved it for me. 发布对话框中的删除额外文件复选框为我解决了这个问题。

重新安装Microsoft.AspNet.WebHelpers适合我

Update-Package –reinstall Microsoft.AspNet.WebHelpers

Just one more suggestion... This was caused for me by some old dll's from an MVC 3 project after upgrading to MVC 5 in the site bin folder on the deployment server. 还有一个建议......这是由部署服务器上的站点bin文件夹中升级到MVC 5后来自MVC 3项目的一些旧dll引起的。 Even though these dll's were no longer used by the code base they appeared to be causing the problem. 即使代码库不再使用这些dll,它们似乎也会导致问题。 Cleaned it all out and re-deployed and it was fine. 把它全部清理干净并重新部署,一切都很好。

You may also get : 您可能还会得到:

Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 无法加载文件或程序集'WebMatrix.Data,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference. 定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)

This has moved to this package 这已经转移到这个包

 Install-Package Microsoft.AspNet.WebPages.Data

You should probably do a clean build before attempting any of the answers to this question and after updating packages 在尝试此问题的任何答案之前以及更新软件包之后,您可能应该进行干净的构建

Here is how I fixed this issue: 以下是我解决此问题的方法:

Open the nuget package manager console and install the below nuget packages: 打开nuget 包管理器控制台并安装以下nuget包:

Install-Package WebMatrix.Data
Install-Package Microsoft.AspNet.WebHelpers
Update-Package

Clean the solution, rebuild and my asp.net web app starts working! 清理解决方案,重建,我的asp.net Web应用程序开始工作!

从bin中删除所有文件然后重建解决方案对我有用。

For me this error was caused by DotNetOpenAuth not being compatible with MVC5 after upgrading from MVC4 to MVC5. 对我来说,这个错误是由于从MVC4升级到MVC5后DotNetOpenAuth与MVC5不兼容造成的。 Uninstalling Microsoft.Web.WebPages.OAuth fixed the problem. 卸载Microsoft.Web.WebPages.OAuth修复了问题。

I have removed it from my references.Then run this in Package Manager Console 我已从我的引用中删除它。然后在包管理器控制台中运行它

Install-Package WebMatrix.Data

Finally add WebMatrix.WebData assembly to references,and rebuild project.It works for me.I hope it solves your problem too. 最后将WebMatrix.WebData程序集添加到引用,并重建项目。它对我有用。我希望它也能解决你的问题。

I installed webapi with it via the helppages nuget package. 我通过helppages nuget包安装了webapi。 That package replaced most of the asp.net mvc 4 binaries with beta versions which didn't work well together with the rest of the project. 该软件包取代了大多数具有beta版本的asp.net mvc 4二进制文件,这些版本与项目的其余部分不能很好地协同工作。 Fix was to restore the original mvc 4 dll's and all was good. 修复是恢复原来的mvc 4 dll,一切都很好。

我遇到了同样的问题,我不得不更新MVC Future(Microsoft.AspNet.Mvc.Futures)

Install-Package Microsoft.AspNet.Mvc.Futures

For me this errors resolved by adding 对我来说,通过添加解决了这个错误

<system.web>
 <trust level="Full">
 </system.web>

in web.config 在web.config中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安全透明方法&#39;WebMatrix.WebData.PreApplicationStartCode.Start()&#39;尝试 - Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' 尝试使用安全透明方法'Microsoft.Web.Helpers.PreApplicationStartCode.Start()'来访问安全关键方法 - Attempt by security transparent method 'Microsoft.Web.Helpers.PreApplicationStartCode.Start()' to access security critical method 尝试通过安全透明方法&#39;system.web.mvc.preapplicationStartcode.start&#39;访问安全关键方法。 - Attempt by security transparent method 'system.web.mvc.preapplicationStartcode.start' to access security critcal method.. failed Webmatrix.WebData登录方法导致异常 - Webmatrix.WebData Login method results in exception 尝试使用安全透明方法xxx来访问安全性关键yy - Attempt by security transparent method xxx to access security critical yy 通过安全透明方法尝试访问安全关键类型失败 - Attempt by security transparent method to access security critical type failed 无法将类型为“System.Web.Security.SqlRoleProvider”的对象强制转换为“WebMatrix.WebData.SimpleRoleProvider” - Unable to cast object of type 'System.Web.Security.SqlRoleProvider' to type 'WebMatrix.WebData.SimpleRoleProvider' 在WPF应用程序中使用WebMatrix.WebData.WebSecurity - Using WebMatrix.WebData.WebSecurity in a WPF application 尝试使用安全透明方法&#39;System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()&#39;来访问安全关键 - Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical 协调WebMatrix.Data和WebMatrix.WebData与Oracle DB一起使用 - Coordination WebMatrix.Data and WebMatrix.WebData work with Oracle DB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM