473,473 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Registry key not being read

I have an C# assembly that is supposed to read a registry key:

RegistryKey regCurrentUser = Registry.CurrentUser;
RegistryKey regSoftware = regCurrentUser.OpenSubKey("Software",true);
RegistryKey regFamily = regSoftware.OpenSubKey("MyCompany", true);
RegistryKey regApp = regFamily.OpenSubKey("MySystem", true);
RegistryKey regSet = regApp.OpenSubKey("Set0", true);
m_strDSN = (string) regSet.GetValue("DSN", m_strDSN);

The string value "DSN" exists under the registry key
\\HKEY_CURRENT_USER\Software\MyCompany\MySystem\Se t0 and definitely
has a value.

This assembly is placed under the /bin subdirectory of my ASP.NET
application. The code executes under the Session_Start event in my
Global.aspx page.

Whenever I start my web application, it doesn't read the registry
setting for the DSN; it always thinks it is null.

I cannot figure out what is wrong. I stepped through the same code on
a different machine and it reads the DSN all right. Help?

Thanks.
Nov 18 '05 #1
2 1954
Granted I really haven't looked through your code to validate that it is
correct, based on your identify of your ASP.Net process (which you haven't
specified) - HKCU is probably not the place you want it - you'd probably
want it in HKLM - but then you'd also need to give the worker process
identity (by default ASPNET) access to the key.

When you step through the code through a debugger - "you" are the current
user - so things work out all right - but I don't believe the ASPNET process
logs on interactively to the machine while executing your web app - so
that's probably where your problem lay.
One tool that you might find useful is RegMon put out by SysInternals
(http://www.sysinternals.com) that tool can help you monitor the registry
and find out why registry calls are failing.
Good Luck!
"Henry Fleming" <ph****@yahoo.com> wrote in message
news:90**************************@posting.google.c om...
I have an C# assembly that is supposed to read a registry key:

RegistryKey regCurrentUser = Registry.CurrentUser;
RegistryKey regSoftware = regCurrentUser.OpenSubKey("Software",true);
RegistryKey regFamily = regSoftware.OpenSubKey("MyCompany", true);
RegistryKey regApp = regFamily.OpenSubKey("MySystem", true);
RegistryKey regSet = regApp.OpenSubKey("Set0", true);
m_strDSN = (string) regSet.GetValue("DSN", m_strDSN);

The string value "DSN" exists under the registry key
\\HKEY_CURRENT_USER\Software\MyCompany\MySystem\Se t0 and definitely
has a value.

This assembly is placed under the /bin subdirectory of my ASP.NET
application. The code executes under the Session_Start event in my
Global.aspx page.

Whenever I start my web application, it doesn't read the registry
setting for the DSN; it always thinks it is null.

I cannot figure out what is wrong. I stepped through the same code on
a different machine and it reads the DSN all right. Help?

Thanks.

Nov 18 '05 #2

What i can suggest you store the registry key in machine level and try. If
you store the key under current User that can not be read by worker process
account. Otherwise change the worker process account to your logged in
account in machine.config file.

Regards,
Govind

"Henry Fleming" wrote:
I have an C# assembly that is supposed to read a registry key:

RegistryKey regCurrentUser = Registry.CurrentUser;
RegistryKey regSoftware = regCurrentUser.OpenSubKey("Software",true);
RegistryKey regFamily = regSoftware.OpenSubKey("MyCompany", true);
RegistryKey regApp = regFamily.OpenSubKey("MySystem", true);
RegistryKey regSet = regApp.OpenSubKey("Set0", true);
m_strDSN = (string) regSet.GetValue("DSN", m_strDSN);

The string value "DSN" exists under the registry key
\\HKEY_CURRENT_USER\Software\MyCompany\MySystem\Se t0 and definitely
has a value.

This assembly is placed under the /bin subdirectory of my ASP.NET
application. The code executes under the Session_Start event in my
Global.aspx page.

Whenever I start my web application, it doesn't read the registry
setting for the DSN; it always thinks it is null.

I cannot figure out what is wrong. I stepped through the same code on
a different machine and it reads the DSN all right. Help?

Thanks.

Nov 18 '05 #3

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

Similar topics

2
by: Bob Olsson | last post by:
Hello all! I´m going to develop a windows smartclient and can´t find the information I need. Where do I store user-settings like paths, background colour and so on. I´ve read an article about...
3
by: Mike Malter | last post by:
On my XP Professional dev machine, I am able to read the registry by giving permissions to the ASP.NET account on the local machine. When I transfer the code to my staging server (Windows 2003),...
6
by: George Hester | last post by:
This location has a parasite checker using javascript. It is in a js file called parasite.js. It is freely available. http://www.doxdesk.com/parasite/ He\She is the only one I trust on the...
3
by: Slimo | last post by:
Hello, I'm searching some example of code (VB) for reading remote registry subkeys and keys. Thanks
4
by: akhare1 | last post by:
OK, before I start, let me clarify a few things here. This is not the run of the mill failure to read a registry key while trying to write to the Event Log. Here's our setup: a) IIS 6.0...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
6
by: Boris | last post by:
Has anyone ever managed to read a Windows registry key in a PHP webpage? I installed the PHP extension win32std and saved their sample script from...
3
by: Aussie Rules | last post by:
Hi, I want to store some data in the registry, however I have not been able to do this, and think my logic maybe flawed. Firstly I try to open the registry and read in any existing values....
6
by: JOSII | last post by:
Getting a string of boolean value into and out of the registry is no problem. Here's the problem: Although you can place an object into the registry and retreive it, I need to place an ArrayList...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
In the Registry at HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text the default key for Text Format is: "Format" = "CSVDelimited" I can use the following OleDB...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.