Why do I get a SecurityException when running from the network?
Hi,
I 'm writing an EXE file using C#. In my EXE, I'm trying to get access to Environment variables. Everything is working fine locally. I have the statement "Environment.GetEnvironmentVariable("TEMP")" which works on my local machine.
As soon as I transfer the program to a networked drive, everytime I run the application it spits out the following error message:
BEGIN SNIP
Unhandled Exception: System.TypeInitializationException: The type initializer for "XVPinpal.validator" threw an
exception. > System.Security.SecurityException: Request for the permission of type System.Security.Permission
s.EnvironmentPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, Co
deAccessPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, Sta
ckCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.GetEnvironmentVariable(String variable)
at XVPinpal.validator.GetEnvironmentVariable(String variable)
at XVPinpal.validator..cctor()
The state of the failed permission was:
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=1.0.5000.0, Culture=neu
tral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="INCLUDE"/>
End of inner exception stack trace
at XVPinpal.validator.Main(String[] args)
END SNIP
Anybody that can shed some light on this? I 'm really confused. I have tried using permission sets, and demanding permission on the environment, but I am at a loss.
Thanks

