32 位 Windows 服务无法在 64 位 Windows 7 上启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7784081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
32-bit windows service do not start on 64-bit windows 7
提问by Mrutyunjay
I have a 32-bit windows .exe. Which will run as windows service. This .exe runs fine as servics for window 2000/xp 32-bit version.
我有一个 32 位的 windows .exe。它将作为 Windows 服务运行。这个 .exe 作为 windows 2000/xp 32 位版本的服务运行良好。
However when try to run on 64-bit windows 2008 server it crash. I am observing two cases.
但是,当尝试在 64 位 Windows 2008 服务器上运行时,它会崩溃。我正在观察两个案例。
1) If I build the application on VC++ 6. From Event log entry it seems to Kernel.dll is crashing.
1) 如果我在 VC++ 6 上构建应用程序。从事件日志条目看来,Kernel.dll 正在崩溃。
Faulting application name: , version: , time stamp: 0x4e6461c0 Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdbdf Exception code: 0xe06d7363 Fault offset: 0x0000b727 Faulting process id: 0xe2c Faulting application start time: 0x01cc83cb1052e4b3 Faulting application path: C:\Program Files (x86)\\Admin.exe Faulting module path: C:\Windows\syswow64\KERNELBASE.dll Report Id: 4e0693b4-efbe-11e0-a07f-001143e8bb9d
2) If I build the application with VS2005 32 bit, A run time error displayed and Event log says msvscrt.dll is crashed.
2) 如果我使用 VS2005 32 位构建应用程序,则会显示运行时错误并且事件日志显示 msvscrt.dll 已崩溃。
Faulting application name: , version: , Faulting module name: MSVCR80.dll, version: 8.0.50727.4927, time stamp: 0x4a2752ff Exception code: 0x40000015 Fault offset: 0x000046b4 Faulting process id: 0x34c Faulting application start time: 0x01cc8c4f2a223426 Faulting application path: C:\Program Files (x86)\\Admin.exe Faulting module path: C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5\MSVCR80.dll Report Id: 69554d57-f842-11e0-a07f-001143e8bb9d
Please help me out resolve this issue.
请帮我解决这个问题。
回答by Branko Dimitrijevic
You need to diagnose the problem better before you can solve it, which probably means finding a way to reproduce it while program is executing under the debugger. Some suggestions:
在解决问题之前,您需要更好地诊断问题,这可能意味着在调试器下执行程序时找到重现问题的方法。一些建议:
Since your service is EXE (and not DLL that runs under svchost.exe, which is a generic host process name for services that run from DLLs), you should be able to use "Attach to Process" option in Visual Studio to attach the debugger to it. You might need to start the Visual Studio as administrator and/or change the user under which the service executes to be able to do that.
由于您的服务是 EXE(而不是在 svchost.exe 下运行的 DLL,它是从 DLL 运行的服务的通用主机进程名称),您应该能够使用 Visual Studio 中的“附加到进程”选项来附加调试器到它。您可能需要以管理员身份启动 Visual Studio 和/或更改执行服务的用户才能执行此操作。
Also, if the service crashes soon after starting, you might need to call MessageBox
with MB_SERVICE_NOTIFICATION
to pause execution long enough so you can attach the debugger.
此外,如果服务在启动后很快崩溃,您可能需要调用MessageBox
withMB_SERVICE_NOTIFICATION
来暂停执行足够长的时间,以便您可以附加调试器。
However, if the service crashes during startup before it even reaches the MessageBox
, you need to
build it as console application. Now you can actually startit under the debugger and see what is going on.
但是,如果服务在启动期间在到达 之前崩溃MessageBox
,您需要将其
构建为控制台应用程序。现在您实际上可以在调试器下启动它,看看发生了什么。
回答by Saurabh
Can you please try installing redistributable packageon client machine to run your application.
您能否尝试在客户端计算机上安装可再发行组件以运行您的应用程序。