Interview Questions

Why do I get a security exception when I try to run my C# app?

C# Interview Questions and Answers


(Continued from previous question...)

88. Why do I get a security exception when I try to run my C# app?

Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is
System.Security.SecurityException.
To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) by using the caspol.exe tool.

(Continued on next question...)

Other Interview Questions