473,395 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Registry write failing when running program from a network drive

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\Solidic a\TestRegistryAccess",RegistryKeyPermissionCheck.R eadWriteSubTree);

if (rk == null)

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

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

rk.Close();

Thanks.
Aug 23 '06 #1
1 1722
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"utpal" <pa***@community.nospamwrote in message
news:u7**************@TK2MSFTNGP06.phx.gbl...
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\Solidic a\TestRegistryAccess",RegistryKeyPermissionCheck.R eadWriteSubTree);

if (rk == null)

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

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

rk.Close();

Thanks.


Aug 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cwnewbe1 | last post by:
I would like to be able to add environment symbols to the Microsoft XP registry. I tried the example in the Python Cookbook by Orielly by running the script locally and it worked fine. Although I...
2
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3...
7
by: Bob | last post by:
I'm working on a Windows app that needs to write to the Registry HKLM. I keep getting a "System.UnauthorizedAccessException: Cannot write to the registry key." error when running the app. I'm...
3
by: Neil Steventon | last post by:
Hi, Just wanted to clarify , if I set up an application that requires the connection for a sql database to setup by the user supplying the username and password to connect, would it be best to...
6
by: Steve Teeples | last post by:
I have a piece of code (written is Visual Studio 2005) that is only reading the Security EventLog. On Windows XP Professiona/Home this code works just fine. int numberOfEntries =...
2
by: Mike | last post by:
Can a vb program running as a serice not use network paths to do file/io? I can't seem to get my program to work with network paths and files. When I use local disk it works fine. When I run it...
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
2
by: rodpolako | last post by:
Hi everyone, I am trying to write a program that can make some changes into a windows XP registry. My program works great when it is working on the local registry. What I want to do is to be...
3
by: MSK | last post by:
Hi I am a newbie to ASP.NET and VBScript, currently I am designing a page to show all the mapped drives using client-side scripts.. I want to read all the mapped drive details (name and Remote...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.