且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows服务错误消息“Windows无法在本地计算机上启动该服务。错误1053:服务未及时响应启动或控制请求“

更新时间:2022-04-03 22:55:19

关于错误消息:此服务无法在本地计算机上启动。

您是否使用Release版本?有时,InstallUtil与Debug一起使用构建,给出此消息。发布版本应该可以正常工作。

参考: http://***.com/a / 7611641 [ ^ ]



如果您觉得这很有用,请给它评分..
Regarding error message : "this service can not start on your local machine."
Do you use Release build?. Sometimes, InstallUtil with the Debug build, gives this message. The Release build should work fine.
Ref: http://***.com/a/7611641[^]

If you find this useful, rate it..


公共部分类MyNewService:ServiceBase

{

private DirectoryInfo imgDir;
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings [b1]。ConnectionString);

string ImgName;

byte [] rImg;

public MyNewService()

{

InitializeComponent();

}

protected覆盖void OnStart(string [] args)

{

//这里我用两种方式调用线程但是它给出了同样的错误

DoLongRunningStartupWork(); //或//
public partial class MyNewService : ServiceBase
{
private DirectoryInfo imgDir;
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["b1"].ConnectionString);
string ImgName;
byte[] rImg;
public MyNewService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
//Here I am calling thread two ways i am doing but it gives same error
DoLongRunningStartupWork(); //or//
(new Thread(() => DoLongRunningStartupWork()){IsBackground = true}) .Start();





}

void DoLongRunningStartupWork()

{

///此部分包含整个程序代码

}



}
void DoLongRunningStartupWork()
{
/// This part contains whole program code
}