LoadLibrary失败,错误4250:此操作仅在应用程序容器的上下文中有效 [英] LoadLibrary fails with error 4250: This operation is only valid in the context of an app container

查看:498
本文介绍了LoadLibrary失败,错误4250:此操作仅在应用程序容器的上下文中有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


LoadLibrary(" my.dll")在使用v120_xp工具集在VS 2013中构建项目时返回正常。但是在VS 2017上使用v141_xp工具集(平台是7.1)它会返回NULL并返回错误代码4250.我确保两次都进行干净的构建。

LoadLibrary("my.dll") returns fine when building my project in VS 2013 with v120_xp toolset. But on VS 2017 with v141_xp toolset (Platform is 7.1) it returns NULL and error code 4250. I made sure to do a clean build both times.


我无法进入LoadLibrary(F11)。

I'm not able to step into LoadLibrary (F11).


执行该行后,ProcessMonitor在CreateFileMapping和NAME NOT FOUND上显示FILE LOCKED WITH ONLY READERS在RegQueryValue上HKLM \ SOFTWARE \ MicroSoft \ Windows \ CurrentVersion \SideBySide \ PrereExternalManifest,但是否则所有成功

After executing that line ProcessMonitor shows FILE LOCKED WITH ONLY READERS on CreateFileMapping and NAME NOT FOUND on HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\PreferExternalManifest on RegQueryValue, but otherwise all SUCCESS


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

dumpbin /headers is same for both versions of my.dll


Dependency Walker有错误,如循环依赖,未解析的导出等。但2013版本的工作似乎有相同的错误。使用VS 2017 my.dll有额外的依赖UCRTBased.dll,vcruntime140d .dll。

Dependency Walker has errors like a circular dependency, unresolved export etc. but the 2013 version that works appears to have the same errors. With VS 2017 my.dll has additional dependency UCRTBased.dll, vcruntime140d.dll.


my.dll与Boost 1.64和TBB静态链接,但这些都是在没有任何Windows商店或通用选项的情况下构建的。我使用的是Windows 10和cmake 3.8。没有更改生成VS解决方案的cmake文件。

my.dll is statically linked against Boost 1.64 & TBB but both those were built without any windows store or universal options. I'm using windows 10 and cmake 3.8. There are no changes to the cmake files that generate the VS solution.


这是依赖性walker配置文件:

Here is the dependency walker profile:


推荐答案

嗨Kalyb,

Hi Kalyb,

感谢您在此处发布。

>> LoadLibrary(" my.dll")在构建我的项目时返回正常VS 2013与v120_xp工具集。但是在使用v141_xp工具集的VS 2017上(平台是7.1)它返回NULL并且错误代码为4250.我确保两次都进行干净的构建。

这听起来很奇怪我。通常,为Windows Universal编译的库不会在本机Win32或编辑器上运行,从而给出错误"此操作仅在应用程序容器的上下文中有效。"

This sounds weird to me. Normally libraries compiled for Windows Universal won't run on native Win32 or the editor, giving you the error "This operation is only valid in the context of an app container.

你能不能请提供有关您的abc.dll和my.dll的更多信息?您是否尝试在vs2017中重建dll文件? 我不太确定是否Boost 1.64& TBB链接了地铁应用程序库。

Could you please provide more information about your abc.dll and my.dll? Have you tried to rebuild your dll file in vs2017?  I'm not quite sure whether if Boost 1.64 & TBB links metro app libraries.

这是一个关于如何调试LoadLibrary失败的博客,你可以参考。

Here is a blog about how to debug LoadLibrary failures, you could refer to.

https://blogs.msdn.microsoft.com/junfeng/2006/11/20/debugging-loadlibrary -failures /

希望这可以帮助你。

最好的问候,

Baron Bi

Baron Bi


这篇关于LoadLibrary失败,错误4250:此操作仅在应用程序容器的上下文中有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆