【问题标题】:ASP.NET SecurityException looking for AspNetHostingPermission During Page ParsingASP.NET SecurityException 在页面解析期间寻找 AspNetHostingPermission
【发布时间】:2009-07-22 15:29:25
【问题描述】:

我在 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 

以前很好用,现在不行了!

请帮帮我!!

【问题讨论】:

标签: .net asp.net


【解决方案1】:

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

【讨论】:

  • 没有希望,我已经这样做了 你的意思是重新启动 PC 或 Visual Studio??
  • PC(有时文件被锁定,重启后会释放)
【解决方案2】:

我不确定为什么它会首先启动,但请记住对父文件夹中 web.config 的更改,并且 machine.config 可能会产生影响。在安装 SharePoint 后,我​​也看到过类似的情况。

您可能想尝试在 web.config 文件的 configuration/system.web 中添加 <trust level="Full" />。如果这可行,那么可能是其他东西正在改变安全级别。

在中等信任环境中托管时,您也可能会看到这些问题。如果您没有使用任何需要完全信任的东西,您可以通过将 [assembly: AllowPartiallyTrustedCallers] 添加到您的 AssemblyInfo 文件中,明确地将您的程序集设置为在部分信任下运行。

另一个想法是检查这里提到的设置:http://geekswithblogs.net/ProjectLawson/archive/2009/05/05/iis-system.web.aspnethostingpermission-exception-on-windows-7-rc.aspx

【讨论】:

    猜你喜欢
    • 2010-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    • 2013-03-18
    • 1970-01-01
    相关资源
    最近更新 更多