Registry write failing when running program from a network drive

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top