嗨,我收到这个错误
无法从命令行或调试器启动服务.首先必须安装winwows服务(使用installutil.exe),然后使用ServerExplorer,Windows Services管理工具或NET START命令启动.
我不明白为什么要发现这个错误.这是我的代码:
{
string Hash = "";
string connectionstring = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(connectionstring);
SqlCommand myCommand = new SqlCommand("GetNullHash", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
SqlDataReader rdr = myCommand.ExecuteReader();
while (rdr.Read())
{
string filename = @"\\" + rdr.GetString(3);
filename = System.IO.Path.Combine(filename, rdr.GetString(2));
filename = System.IO.Path.Combine(filename, rdr.GetString(1));
Hash = rdr.GetString(0);
Hash = computeHash(filename);
}
myConnection.Close();
return Hash;
}
Run Code Online (Sandbox Code Playgroud) 我阅读了有关该主题的MSDN文章.报价:
由于服务必须在服务控制管理器的上下文中而不是在Visual Studio中运行,因此调试服务并不像调试其他Visual Studio应用程序类型那样简单.要调试服务,必须启动该服务,然后将调试器附加到运行它的进程.然后,您可以使用Visual Studio的所有标准调试功能来调试应用程序.
现在我的问题是我的服务首先无法启动.首先它崩溃,并说:
MyServiceName.exe [3596]中发生未处理的异常(System.Runtime.InteropServices.COMException)
并建议我调试它(当我选择一个时,调试器实例会立即崩溃).然后它说
无法在本地计算机上启动MyServiceName服务.错误1053:服务未及时响应启动或控制请求
那么,我如何调查/调试我的服务无法启动的原因?问题是我创建了一个控制台应用程序,它完全可以完成服务的工作,并且工作正常.(我的意思是我只是将OnStart()方法和主循环的内容复制到main中.
任何帮助,将不胜感激.
该服务是用C#编写的,大量使用互操作.我正在使用VS2008
我已经创建了一个Windows服务并将其安装在服务器上.它似乎工作得很好,即做其意图.但是当我通过远程桌面登录服务器时,我收到以下消息:
无法从命令行或调试器启动服务.首先必须安装Windows服务(使用installutil.exe),然后使用ServerExplorer,Windows服务管理工具或NET START命令启动.
我点击然后转到服务资源管理器检查服务,它开始正常.没有错误报告.
我安装了这个,所以它使用Local System作为"Log On As".
谢谢.