Re: Registry key not being read
From: Jediah L. (rife_at_nospam.nospam)
Date: 09/01/04
- Next message: Jediah L.: "Re: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."
- Previous message: Ken Schaefer: "Re: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."
- In reply to: Henry Fleming: "Registry key not being read"
- Next in thread: Govind: "RE: Registry key not being read"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 31 Aug 2004 23:23:40 -0400
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" <ph8794@yahoo.com> wrote in message
news:90cc3865.0408311908.1a0176f5@posting.google.com...
>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\Set0 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.
- Next message: Jediah L.: "Re: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."
- Previous message: Ken Schaefer: "Re: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."
- In reply to: Henry Fleming: "Registry key not being read"
- Next in thread: Govind: "RE: Registry key not being read"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|