Registry write failing when running program from a network drive

  • Thread starter Thread starter utpal
  • Start date Start date
U

utpal

Hi,
My CSharp program, when I run from the local drive it can create/modify
registry. However running the program from a network drive, gives
RegistryPremission error. I don't belive that just by running the program
from a network drive, the program will try to access the registry of the
network machine. Here is the code snippet:
RegistryKey rk =
Registry.CurrentUser.OpenSubKey(@"Software\Solidica\TestRegistryAccess",RegistryKeyPermissionCheck.ReadWriteSubTree);

if (rk == null)

rk =
Registry.CurrentUser.CreateSubKey(@"Software\Solidica\TestRegistryAccess");

rk.SetValue(this.textBoxName.Text, this.textBoxValue.Text);

rk.Close();

Thanks.
 
When running from a network location, .NET places limitations on what
the program can do. The idea behind this is that if you are getting the
code from somewhere that you don't trust, then it shouldn't be able to
access or modify resources on your machine.

To get around this, I would assign a strong-name to your assembly.
Then, you can go to the .NET configuration tool and assign the permissions
you need to your assembly based on the strong name.

Hope this helps.
 
Back
Top