This error occurred when trying to run code that accessed the System.DirectoryServices namespace.
To work around this, just open up your .NET 2.0 security:
- Start the .NET Framework 2.0 Configuration tool (from Administrative Tools).
- Expand Runtime Security Policy.
- Expand User - Code Groups and right-click on All_Code and select Properties.
- On the Membership Condition tab make sure All Code is selected in the dropdownlist.
- On the Permission Set tab make sure FullTrust is selected in the dropdownlist.
- Click OK
- Under Runtime Security Policy, expand Machine - Code Groups and right-click on All_Code and select Properties.
- Perform steps 4 - 6.
HTH
Tim