LoadLibrary失败带有错误4250:此操作仅在应用程序容器的上下文中有效

LoadLibrary fails with error 4250: This operation is only valid in the context of an app container

本文关键字:应用程序 上下文 有效 有错误 失败 4250 操作 LoadLibrary      更新时间:2023-10-16

loadLibrary(" my.dll")在使用VS 2013中使用V120_XP工具集构建我的项目时返回正常。但是在使用V141_xp工具集(平台为7.1)的VS 2017上,它返回null和错误代码4250。我确保两次都进行干净的构建。

我无法踏入LoadLibrary(F11)。

执行该行后,ProcessMonitor在createFileMapping上显示锁定的文件,并在HKLM Software Microsoft Microsoft Windows Windows currentversion sidebyside sidebyside preferexternalManifest上锁定,但否则所有成功

dumpbin/标题对于my.dll的两个版本都相同

依赖性沃克(Walker)具有循环依赖性,未解决的导出等的错误,但是工作的2013版似乎具有相同的错误。使用VS 2017 my.dll具有额外的依赖关系UCRTBASED.DLL,vcruntime140d.dll。

my.dll在静态上链接,而不是boost 1.64&TBB,但两者都是没有任何Windows商店或通用选项的。我正在使用Windows 10和Cmake 3.8。生成VS解决方案的CMAKE文件没有更改。

这是依赖关系沃克个人资料:

LoadLibraryA("my.dll") called from "d:myprojectx64debugmy.EXE" at address 0x00007FF7FCED1DA2.
Loaded "d:myprojectx64debugmy.DLL" at address 0x00007FFA49D40000.  Successfully hooked module.
Loaded "d:myprojectx64debugabc.DLL" at address 0x00007FFA45190000.  Successfully hooked module.
Loaded "c:windowssystem32OLEAUT32.DLL" at address 0x00007FFA839F0000.  Successfully hooked module.
Loaded "c:windowssystem32MSVCP_WIN.DLL" at address 0x00007FFA83010000.  Successfully hooked module.
Loaded "c:windowssystem32OLE32.DLL" at address 0x00007FFA83750000.  Successfully hooked module.
Loaded "d:myprojectx64debugdef.DLL" at address 0x00007FFA67FD0000.  Successfully hooked module.
Loaded "d:myprojectx64debugTBB_DEBUG.DLL" at address 0x00007FFA62BE0000.  Successfully hooked module.
Unloaded "d:myprojectx64debugabc.DLL" at address 0x00007FFA45190000.
Unloaded "d:myprojectx64debugTBB_DEBUG.DLL" at address 0x00007FFA62BE0000.
Unloaded "c:windowssystem32MSVCP_WIN.DLL" at address 0x00007FFA83010000.
Unloaded "c:windowssystem32OLEAUT32.DLL" at address 0x00007FFA839F0000.
Unloaded "c:windowssystem32OLE32.DLL" at address 0x00007FFA83750000.
Unloaded "d:myprojectx64debugdef.DLL" at address 0x00007FFA67FD0000.
Unloaded "d:myprojectx64debugmy.DLL" at address 0x00007FFA49D40000.
LoadLibraryA("my.dll") returned NULL. Error: This operation is only valid in the context of an app container (4250).

检查程序是否从您认为的位置运行(如果您的程序不更改当前目录本身,则项目设置的调试部分的工作目录)。