jump to navigation

SecurityException when Remote Debugging with VS2005 May 31, 2007

Posted by codinglifestyle in Security.
Tags: , , , , , ,
add a comment

You may run in to a situation where you are remote debugging an application (a simple console program in my case) and receive a security exception like this:

System.Security.SecurityException was unhandled

Message: Request for the permission of type ‘Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ failed.

The interesting thing was the program executed properly when run directly on the server.  However, when run via the remote debugger the problem cropped up.  I figured .NET v2 Configuration Manager was the right place to fix the problem but we no longer have the wizard which includes “Trust an assembly”.  Before finding the solution I did try caspol.exe –af file.exe but this did not work.  Finally I found the solution as follows:

 

  1. Strongly name your assembly
  2. Open ‘.NET Framework 2.0 Configuration’ from Administrative Tools
  3. Under Runtime Security Policy->Enterprise->Code Groups->All_Code right click and select New
  4. Give the new Code Group a name and description and click Next
  5. Select Strong Name as the condition type
  6. Press the Import button to import the Public Key and click Next
  7. Click Finish to create the code group
  8. Edit the properties of the newly created group
  9. Ensure the ‘Policy levels below this level will not be evaluated’ is checked

 

You should now be able to remotely debug any program strongly named with the specified public key.