Error Compiling and Publishing Website in Visual Studio 2005
I was getting the following compilation error when trying to publish or build my website that I was working on in Visual Studio 2005:
Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
I was running Visual Studio 2005 on my workstation and my website was on a web server and I had a local drive letter (Y:) mapped to that folder. I was trying to publish to another web server that I had mapped to (X:). By following these steps, the error went away, the site compiled and I was able to publish it:
Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
I was running Visual Studio 2005 on my workstation and my website was on a web server and I had a local drive letter (Y:) mapped to that folder. I was trying to publish to another web server that I had mapped to (X:). By following these steps, the error went away, the site compiled and I was able to publish it:
- On the workstation that you're developing on, go to Administrative Tools > Microsoft .NET Framework 2.0 Configuration
- Expand to .Net Framework 2.0 Configuration > My Computer > Runtime Security Policy > Machine > Code Groups > All_Code.
- Right click the All_Code node and choose New.
- Call the new code group anything you'd like and click the Next button.
- From the pulldown choose "URL" and in the URL textbox that displays type:
file:////\\y:\* - Click the Next button.
- Select the "Use existing permission set" pulldown and select "Full Trust".
- Close Visual Studio 2005, open it again and it should compile.