Windows Service导入C ++非托管代码

时间:2022-09-01 09:29:44

I have both windows service and C++ unmanaged code("External.DLL") that were built x86 and the windows service calls one of the "External.DLL" functions that writes/reads in registry. When I start the service as an administrator the windows service crashes for timeout reason. To troubleshoot the problem, I made a log file, I wrote an instruction of logging before the instruction of calling the external function and another one just after. In the log file I have got the "Before" log message and not the "After", and there is not exception catched. PS: I have a console application that can access and calls the External.DLL functions. what can I do ? What can I add as configuration for windows service project ?

我有构建x86的Windows服务和C ++非托管代码(“External.DLL”),Windows服务调用在注册表中写入/读取的“External.DLL”函数之一。当我以管理员身份启动服务时,Windows服务因超时原因而崩溃。为了解决这个问题,我制作了一个日志文件,我在调用外部函数的指令之前编写了一个日志记录指令,之后又写了另一个。在日志文件中,我有“之前”日志消息,而不是“之后”,并且没有捕获异常。 PS:我有一个控制台应用程序,可以访问和调用External.DLL函数。我能做什么 ?我可以添加什么作为Windows服务项目的配置?

1 个解决方案

#1


0  

In the external function, an "afxMessageBox" was written in the beginning of the function. So it blocks the windows service start.

在外部函数中,在函数的开头写入了“afxMessageBox”。所以它阻止了Windows服务的启动。

#1


0  

In the external function, an "afxMessageBox" was written in the beginning of the function. So it blocks the windows service start.

在外部函数中,在函数的开头写入了“afxMessageBox”。所以它阻止了Windows服务的启动。