RegistryPermission error when called from a C # console application
Just find some kind of pointer before I go down the wrong path. I wrote a small C # console application that opens, reads, writes and deletes both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER from our user registry
Of course, I got it to work on my PC and the entire test PC, but one of our clients gets an error when they try to run the .exe
System.Security.SecurityException: A permission request of type 'System.Security.Permissions.RegistryPermission, mscorlib, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check (object request, StackCrawlMark & stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand () at Microsoft.Win32.RegistryKey.CheckSubKeyReadPermission (Microsoft String. subkeyName) at Microsoft.Win32.RegistryKey.CheckSubKeyReadPermission (Microsoft String. String subkeyName, Boolean> subKeyWritable) at Microsoft.Win32.RegistryKey.OpenSubKey (string name, Boolean writeable) at EstateMasterClearReg.Program.Main (String [] args)
Failed to complete action:
Demand. First Invalid Permission Type: System.Security.Permissions.RegistryPermission Build Failure Zone: Intranet
Since I won't be able to test this on client computers (and they said they are running locally and registering as Admin) is there anything I can do to make sure the application will work on any machine?
Do I need to use a strong name key and AllowPartiallyTrustedCallers, or do I need to use System.Security.Permissions.RegistryPermission?
Thanks for your help.
a source to share
It looks like they can run your executable over the network. Ask them to try copying it to their local hard drive and running it again. The permissions assigned to the executable differ between running from a network share and running from the local file system.
Alternatively, it is possible that they changed the default security settings, so even if they are running locally, they are considered part of the intranet zone. Check them out too.
Tips might also be helpful here:
http://blogs.msdn.com/shawnfa/archive/2003/06/20/57023.aspx
Please note that if you give your assembly a strong name, you will still need to change your local security policy to give your assembly the appropriate permissions. A strong name alone will not grant additional permission.
a source to share