Using ASP.NET AJAX (and other DLLs) in a remote debugging environment
My development environment involves working on code that is not stored locally on my machine, but on a centralized development server on our network. I like working this way because it allows me to decouple my computer from IIS, and running the remote debugger (comes on the Visual Studio 2005 DVD) is really simple.
However, a problem arises when you try to run certain assemblies from a your remote development machine -- you get compilation errors telling you that an assembly can't be loaded because permission request problems. I first noticed this issue when I started using the ASP.NET AJAX (formerly Atlas) binary builds. You will get one of the following two error messages when you try to build your project:
1) Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=xxxx' failed.
2) ASP.NET runtime error: Could not load file or assembly 'Microsoft.Practices.ObjectBuilder, Version=1.0.51205.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. [Note: The specific assembly information may differ depending on your project]
These errors occur because your remote development environment does not have enough permission to compile the ASP.NET AJAX (or other) DLLs on your system [For a nice explanation of Code Access Security, see http://www.15seconds.com/issue/040121.htm]. In order to give your remote development environment permission, you need to configure the Code Groups inside of the .NET Framework 2.0 Configuration MMC to allow your local intranet to be fully trusted by your machine. To do this, follow these steps on your development (local) computer:
- Go to Control Panel-->Administrative Tools on your computer.
- Click on .NET Framework 2.0 Configuration.
- Drill down to My Computer --> Runtime Security Policy --> Machine --> Code Groups --> All Code --> LocalIntranet Zone.
- Right click on LocalIntranet Zone, and choose Properties.
- Click on the Permission Set Tab and change the Permission Set to 201CFull Trust201D.
- Hit Apply and OK and close the .NET 2.0 Framework Configuration window.
- Restart Visual Studio
Now you should be able to build, debug and run your project with your ASP.NET AJAX DLLs included in the BIN folder. Happy Coding!
PS: I have heard that adding the problem DLLs to your GAC (on your machine and the remote development machine) will fix the problem, but I have not verified this. I did not want to do this in my environment because we work with different versions of AJAX and other DLLs and I want to keep different versions by project.