Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WebService
Hi everyone!
 
I use a webservice in order to get and return Registry value.
For explicit more, example follow:
 
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("Software\\Yahoo\\Pager");
string sUserName = regKey.GetValue("Yahoo! User ID").ToString();
regKey.Close();
 
In winform application, I can get 'sUserName' variable easily, but I can't get it on a webservice, it throws exception: "Object reference not set to an instance of an object"
 
Experts can help me in this regard?
Thanks so much in advance!
Posted 14-Mar-11 19:09pm
Edited 16-Mar-11 23:22pm
Dalek Dave432.9K
v4
Comments
Dalek Dave at 17-Mar-11 4:22am
   
Edited for Grammar and Readability.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It looks like you might be having permission issues.
Have a look here[^].
  Permalink  
Comments
Dalek Dave at 17-Mar-11 4:22am
   
Good Link
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I believe IIS use other account like ASP.NET account.
from your code what I see is the it query on the current user.
so basically the current user will be the ASP.NET account.
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("Software\\Yahoo\\Pager");
will always return null.
try to use the Impersonation feature of ASP.NET.
  Permalink  
v2
Comments
Dalek Dave at 17-Mar-11 4:22am
   
Sage Advice.
danghieunhoc at 19-Apr-11 23:54pm
   
Sorry for waiting so long time, i was busy for other project.
 
I tried the same way as your guide but it failed. I tried all of Windows rights but it still doesn't ok. Could you tell my mistake, pls?
Link follow: 'http://www.mediafire.com/?y55igzyhc5ob7wk'
 
Tks you very much!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I have tried all ways like: set Full control, set Folder Permissions, set Registry Permissions... etc but i don't successful.
You can see demo project follow: 'http://www.mediafire.com/?y55igzyhc5ob7wk'. I built it by Visual Studio 2005. Debugging-(F5) is ok, but run it as a site through IIS is not successful.
 
Other any way, please help me, tks!
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

How can i make it? Can anyone help me? T_T
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

You are trying to access the registry sub-key for the currently logged in user? If so you need to first verify that a user is actually logged in, and then you need to read from the user's specific sub-registry. It could either be via impersonation or via directly specifying the full registry path (CurrentUser will obviously not work). You will also need to deal with permission issues involved in doing this.
  Permalink  
Comments
danghieunhoc at 27-Apr-11 4:19am
   
I tried setting permissions for IIS, but it didn't get 'sUserName' variable. User logged in or not, not important, bcz i run normally in application environment, but in IIS don't.
 
Do u tell me more explicit?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 519
2 Maciej Los 305
3 BillWoodruff 250
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 27 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100