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=, 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.


Convert a DLL to have a Strong Name using it’s Type Library and TLBIMP January 24, 2006

Posted by codinglifestyle in Security.
Tags: ,

Recently I was adding interop.wialib to a strongly named project.  As wialib wasn’t strongly named I got the following error:

Assembly generation failed – Referenecd assembly ‘Interop.WIALib’ does not have a strong name

I then came across this excellent tip from CodeProject which allows you to strongly name many of Microsoft assemblies:

The steps are
1) Create a key:
     sn -k keypair.snk

2) Rebuild the com object;
tlbimp OldDll.tlb /out:NewDll.dll /keyfile:keypair.snk

3) Remove the OldDll.dll from the project references

4) Add NewDll.dll the project

5) Full rebuild