简体   繁体   English

作为服务启动时,LoadLibrary有时会失败

[英]LoadLibrary fails sometimes when starting as service

We have a 64bit application running as service on Windows 7 64bit. 我们有一个64位应用程序在Windows 7 64位上作为服务运行。 When we start a service manually, it works fine everytime. 当我们手动启动服务时,它每次都能正常运行。 When the service is started automatically with system startup, sometimes (like 1 in 10) it fails. 当服务随着系统启动自动启动时,有时(如十分之一)将失败。 Problem is with LoadLibrary function which is in fact the first thing it does. 问题是LoadLibrary函数,实际上这是它要做的第一件事。 It is a load of our DLL where the most of the code is. 大多数代码是我们DLL的负载。 I can't reproduce it on my computers, so I am just sending special testing binaries to colleague abroad. 我无法在计算机上复制它,因此我只是将特殊的测试二进制文件发送给国外的同事。 I added text outputs to file using unbuffered write operation so I can see exactly where it disappears. 我使用无缓冲写操作将文本输出添加到文件中,因此我可以确切看到它消失的位置。 There is no crash dump, there is no exception, there is no NULL retrived, it just exits somewhere in LoadLibrary and service is not running after system startup. 没有崩溃转储,也没有异常,没有检索到NULL,它只是在LoadLibrary中的某个位置退出,并且系统启动后服务未运行。 Our library does not have DllMain, but if I add it, it does not get there (in fail case). 我们的库没有DllMain,但是如果我添加它,它就不会到达那里(在失败的情况下)。 I tried delay loading of dependent system libraries, no success. 我尝试延迟加载依赖系统库,但没有成功。 It seems like sometimes something is not yet started in Windows and so the initialization fails, I am not sure. 似乎有时Windows中尚未启动某些内容,因此初始化失败,我不确定。 But adding sleep before LoadLibrary does not solve the problem (too late to sleep?). 但是在LoadLibrary之前添加睡眠不能解决问题(睡得太晚了吗?)。 Do you have any ideas what is going on and how to proceed? 您有什么想法吗?如何进行? I am currently going to remove the code from our DLL step by step to remove the lib dependencies one by one to see if in some moment it will start to work. 我当前将逐步从DLL中删除代码,以一步一步地删除lib依赖项,以查看它是否会在某些时候开始工作。 I will be happy to provide additional information when needed. 我将很乐意在需要时提供其他信息。

Lenovo RapidBoot Shield app was the reason. 原因是Lenovo RapidBoot Shield应用程序。

"RapidBoot Shield works by delaying non-critical applications and services to help your system boot faster. However, in some instances, RapidBoot Shield may delay an application and/or service that is critical to the system startup. This can cause the system to boot slower than expected or some applications may be unable to start normally." “ RapidBoot Shield通过延迟非关键的应用程序和服务来帮助您的系统更快地启动。但是,在某些情况下,RapidBoot Shield可能会延迟对系统启动至关重要的应用程序和/或服务。这可能导致系统启动。慢于预期,否则某些应用程序可能无法正常启动。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM