Reputation:
I am getting the following error while i debugging my project in VS 2008 developer edition
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
Previously it was working fine , now its not!
Please help me!!
Upvotes: 1
Views: 1422
Reputation:
I'm not sure why it would have started in the first place, but remember changes to the web.config in parent folders and the machine.config can have an impact. I have also seen things like this happen after SharePoint is installed.
You may want to try adding <trust level="Full" />
in configuration/system.web in your web.config file. If that works, then it is probably something else that is changing the security level.
You may also see these issues when hosting in a medium trust environment. If you are not using anything that requires full trust, you can explicitly set your assemblies to run under partial trust by adding [assembly: AllowPartiallyTrustedCallers] to you AssemblyInfo file.
Another thought is to check out the setting mentioned here: http://geekswithblogs.net/ProjectLawson/archive/2009/05/05/iis-system.web.aspnethostingpermission-exception-on-windows-7-rc.aspx
Upvotes: 1
Reputation: 39413
Strange cases like this often goes away cleaning your project (right-clic -> Clean) and rebooting.
Upvotes: 1