Re: Registry key not being read

From: Jediah L. (rife_at_nospam.nospam)
Date: 09/01/04


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.



Relevant Pages

  • Create a DSN programmatically with network options
    ... I would like to create a brand new system DSN, programmatically, ... Relying on this single registry entry is not enough since it only ... least for SQL Server). ... networking options cannot be set ...
    (microsoft.public.sqlserver.odbc)
  • Re: creating odbc dsn with c#
    ... add the appropiate registry entries for the DSN. ... Create a new DSN with your desired properties via the control panel ... uses ODBC DSNs to connect to multiple access databases. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Inno User Input Form and ODBC DSN
    ... DSNs are strictly registry entries. ... why bother with a DSN? ... It is an ODBC System DSN. ... > login, Password, and Database. ...
    (microsoft.public.vb.general.discussion)
  • Re: Inno User Input Form and ODBC DSN
    ... DSNs are strictly registry entries. ... why bother with a DSN? ... It is an ODBC System DSN. ... > login, Password, and Database. ...
    (microsoft.public.vb.database)
  • Re: Microsoft Access DB Driver for JDBC
    ... The jdbc odbc bridge works but ... > I don't know of any classes for manipulating the registry (I'm new to ... > If you can find a Java class for registry manipulation coding this is ... You don't need a DSN for accessing Access DBs. ...
    (comp.lang.java.programmer)