Web服务无法调用注册表GetValue函数? [英] Webservice can't call Registry GetValue function?

查看:74
本文介绍了Web服务无法调用注册表GetValue函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我使用Web服务来获取并返回注册表值.
有关更多详细信息,请参见以下示例:

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();



在Winform应用程序中,我可以轻松地获得"sUserName"变量,但无法在Web服务上获取它,它引发异常:对象引用未设置为对象的实例"

专家可以在这方面帮助我吗?



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!

推荐答案

您似乎有权限问题.
此处查看一下 [
It looks like you might be having permission issues.
Have a look here[^].


我相信IIS使用其他帐户,例如ASP.NET帐户.
从您的代码中,我看到的是当前用户的it查询.
因此基本上,当前用户将是ASP.NET帐户.
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");


将始终返回null.
尝试使用ASP.NET的
假冒功能.


will always return null.
try to use the Impersonation feature of ASP.NET.


我已经尝试了所有像这样的方式:设置完全控制,设置文件夹权限,设置注册表权限...等等,但我没有成功.
您可以看到演示项目,其网址为:"http://www.mediafire.com/?y55igzyhc5ob7wk".我用Visual Studio 2005构建了它.Debugging-(F5)可以,但是不能通过IIS在站点上运行.

其他任何方式,请帮我,tks!
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!


这篇关于Web服务无法调用注册表GetValue函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆