Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:25:47+00:00 2026-06-11T07:25:47+00:00

I’ve looked at a couple of StackOverflow threads now. This comes closest. I’m stuck

  • 0

I’ve looked at a couple of StackOverflow threads now. This comes closest.

I’m stuck using VS2005, and .NET 2.0. The server is Win2008. Not R2.

I’m building a C# ASP.NET web application that reads information from a database that’s modified by a VB6 application. The database configuration settings are stored in the registry.

I’m using the Registry.GetValue() function and it’s returning a null value.

If I make the Application Pool run as Administrator, the code returns the expected value. With any other user, the ToString throws a System.NullReferenceException. I have tried the following:

  1. Making the AppPool use and assigning Full Control to the following users does not work:
    1. NT AUTHORITY\NETWORK SERVICE
    2. NT AUTHORITY\SYSTEM
    3. NT AUTHORITY\LOCAL SERVICE
    4. A custom user in the Administrators group.
  2. I cannot apply permissions to IIS APPPOOL\DefaultAppPool because the user doesn’t seem to exist. This is a documented fault of Server 2008.
  3. If I make the AppPool use the Administrator account, the system works.

Attached is the relevant code:

string root = "HKEY_CURRENT_USER";
string keyName = @"Software\Some\Key\Somewhere\";
string valueName = "someValue";
string fullKey = root + @"\" + keyName;
object keyValue;
try
{
    keyValue = Registry.GetValue(fullKey, valueName, "Value not found.");
    string val = keyValue.ToString();
    return val;
}
catch (Exception ex)
{
    return ex.GetType().ToString();
}

Unless it’s running as Administrator, the above code always returns a System.NullReferenceException when running keyValue.ToString(). It never throws the System.Security.SecurityException.

I’m not eager to make my web app require Admin access.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:25:48+00:00Added an answer on June 11, 2026 at 7:25 am

    You are searching under the key for the current user. Clearly the data exists under the key for the Administrator but not for the other users.

    For the service accounts that don’t have a profile, HKEY_CURRENT_USER resolves to HKEY_USERS.Default.

    So to make it work with service accounts, you need to add the value to

    HKEY_USERS\.Default\Software\Some\Key\Somewhere\
    

    To make it work for the custom user in the Administrators group, you need to add it to

    HKEY_USERS\<sid>\Software\Some\Key\Somewhere\
    

    where is the SID of the custom user.

    This isn’t related to needing Admin access, you’re just looking in the wrong place!

    If the data isn’t user-specific, try putting it in:

    HKEY_LOCAL_MACHINE\Software\Some\Key\Somewhere\
    

    then all the users will normally be able to read the same value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.