无法在 Windows XP Embedded 上启动用 .NET 2.0 编写的服务
我创建了一个小型可执行文件,可以通过调用 MyApp.exe
作为普通应用程序启动,也可以通过调用 MyApp.exe -s
作为服务启动。因为我试图保持尽可能简单,所以我通过手动运行“安装”此应用程序,
sc create MyAppService binPath= "C:\MyApp\MyApp.exe -s"
然后像平常一样使用 net start MyAppService
启动服务。
在两台 Windows XP 计算机和两台 Windows 2000 计算机上,此方法运行良好。但是,在两台不同的 Windows XP Embedded 计算机上,当我尝试启动该服务时,我收到消息:
发生系统错误 1083。
配置此服务运行的可执行程序未实现该服务。
在一台机器上,我可以通过卸载并重新安装 .NET 2.0 来修复此问题,但在第二台机器上这不起作用。
我不知道如何调试这个问题,搜索 google 似乎只能找到因此消息而失败的特定服务,例如 BITS 和 Exchange 服务。
下面是类 MyApp
(启动类)和 MyAppService
(扩展 ServiceBase 的类)。预先感谢您对此的任何指示。
MyApp.cs
static class MyApp
{
[STAThread] static void Main( string[] args )
{
....
switch ( arg1 )
{
case "-s":
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new MyAppService() };
ServiceBase.Run( ServicesToRun );
break;
....
}
}
}
MyAppService.cs:
class MyAppService : ServiceBase
{
static MyAppService()
{
// ...
}
protected override void OnStart( string[] args )
{
// ...
}
}
I've created a small executable that can be launched either as a normal application by calling MyApp.exe
or as a service by calling MyApp.exe -s
. Because I'm trying to keep as simple as possible, I "install" this app by manually running
sc create MyAppService binPath= "C:\MyApp\MyApp.exe -s"
Then I start the service with net start MyAppService
like normal.
On two Windows XP machines and two Windows 2000 machines, this works fine. However, on two different Windows XP Embedded machines, when I try to start the service I get the message:
System error 1083 has occurred.
The executable program that this service is configured to run in does not implement the service.
On one machine, I was able to fix this by uninstalling and reinstalling .NET 2.0, but on the second machine this did not work.
I'm not sure how to go about debugging this, and searching google only seems to turn up specific services that fail with this message such as BITS and an Exchange service.
Below are the classes MyApp
, which is the startup class, and MyAppService
, which is the class that extends ServiceBase. Thanks in advance for any direction on this.
MyApp.cs
static class MyApp
{
[STAThread] static void Main( string[] args )
{
....
switch ( arg1 )
{
case "-s":
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new MyAppService() };
ServiceBase.Run( ServicesToRun );
break;
....
}
}
}
MyAppService.cs:
class MyAppService : ServiceBase
{
static MyAppService()
{
// ...
}
protected override void OnStart( string[] args )
{
// ...
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在桌面上,如果服务未在 svchost 实例应运行的帐户下的 Windows 注册表中正确注册,则可能会发生这种情况。我没有 XPe 经验,但尝试查看 HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost 并确保为该帐户正确列出了 MyAppService。
On the desktop, this can happen if the service isn't registered correctly in the Windows Registry under the account that the svchost instance is supposed to run under. I don't have experience in XPe, but try looking in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost and make sure that MyAppService is correctly listed for the account.
看来我也有同样的问题。 ServiceController.Start() 未成功启动服务。该应用程序采用 C# .NET2 编写,并在 Window XPe 中运行。解决方法如下:
循环2或3次后,服务通常会成功启动。
但30-40秒过去了。这是不可接受的。
有人在这个问题上有过经验吗?谢谢!
It appears that I have the same problem. The ServiceController.Start() does not start service successfully. The application is in C# .NET2 and running in Window XPe. The work around is below:
after looping 2 or 3 times, the service usually get started successfully.
But 30-40 seconds has passed. This is not acceptable.
Dos anybody have experienced on this issue? Thanks!