我有一个问题,我无法解决两天。HttpWebResponse:Windows服务与控制台应用程序
在一个控制台应用程序,此代码工作正常:
url="http://www.reuters.com/finance/currencies/quote?srcAmt=1.00&srcCurr=USD&destAmt=&destCurr=ASD&historicalDate=MMddyyyy"
HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
req.Timeout = 3000000;
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
{
// ...
}
但在我的Windows服务,GetResponse()
被抛出异常,“远程名称无法解析:www.reuters.com'” 。
我不知道我在做什么错,也许我在ServiceInstaller
设置错误。
感谢您向我展示正确的曲目,但还有一个额外的问题。
我正在虚拟机上工作(我有管理员权限,但我根本没有管理经验)。
如果我在用户的服务安装程序中设置帐户(并提供我的登录信息),那么我在连接数据库(Odbc)时遇到问题。连接打开抛出我:
ERROR [08001] [MERANT][ODBC Sybase driver]
Allocation of a Sybase Open Client Context failed.
Sybase normally generates a SYBINIT.ERR file containing more specific reasons for failing.\r\n
ERROR [01S00] [MERANT][ODBC Sybase driver]
Invalid attribute in connection string: Port.
因此,如果ServiceInstaller
我无法连接到数据库,否则,如果我设置帐户为LocalSystem我可以打开连接到数据库,但我不能使用GetResponse()
组帐户用户。
所以问题是,我应该怎么做,当一切都放在Windows终端服务器?
我想可能会有一些与管理权限搞砸的东西。我能做些什么来解决这个问题?再次感谢。