在页分析期间查找AspNetHostingPermission时发生ASP.NET安全异常

ws51t4hk  于 2022-12-14  发布在  .NET
关注(0)|答案(2)|浏览(136)

我在VS 2008开发人员版中调试项目时遇到以下错误

Server Error in '/' Application.
--------------------------------------------------------------------------------

Security Exception 
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 

[SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a77a5c561934e089' failed.]
   System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0
   System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +42
   System.Web.UI.Util.GetTypeFromAssemblies(ICollection assemblies, String typeName, Boolean ignoreCase) +145
   System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) +73
   System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +111
   System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) +279



--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

以前它工作正常,现在不是了!
请救救我!!

wbgh16ku

wbgh16ku1#

像这样的奇怪情况通常会在清理项目(右键单击-〉清理)和重新启动后消失。

ffscu2ro

ffscu2ro2#

我不知道为什么它会在第一时间启动,但请记住,对父文件夹中的web.config和machine.config的更改可能会产生影响。我也见过安装SharePoint后发生类似的事情。
你可以尝试在web.config文件的configuration/system.web中添加<trust level="Full" />,如果可以,那么可能是其他东西改变了安全级别。
在中等信任环境中承载时,也可能会遇到这些问题。如果不使用需要完全信任的任何内容,则可以通过添加[assembly:AllowPartiallyTrustedCallers]添加到程序集信息文件中。
另一个想法是检查这里提到的设置:http://geekswithblogs.net/ProjectLawson/archive/2009/05/05/iis-system.web.aspnethostingpermission-exception-on-windows-7-rc.aspx

相关问题