混合模式 MFC 应用程序在 VS2008 中未正确初始化

发布于 2024-07-25 17:27:00 字数 727 浏览 2 评论 0原文

我已将混合模式 MFC 应用程序从 VS2005 转换为 VS2008。 它编译正常,但启动应用程序时,我在 afxwin1.inl 中得到一个断言,因为 afxCurrentResourceHandle = NULL。

这是在调用 MyCWinApp::InitInstance 之前。 调用堆栈是

mfc90d.dll->AfxWinInit (with HINSTANCE = NULL)
myapp.exe!InternalDllMain
myapp.exe!PostDllMain
myapp.exe!dynamic intilizer for postDllMain::A0x61ae6c8e

VS2005 中的同一项目启动正常,我注意到调用的不是 PostDllMain,而是调用 WinMainCRTStarup,它获得一个定义的实例句柄:

mfc80d.dll!AfxWinInit (with HINSTANCE = 0x0040000)
mfc80d.dll!AfxWinMain
myApp.exe!WinMain
myApp.exe!__tmainCRTStartup
myapp.exe!WinMainCRTStartup

该应用程序使用 /clr 进行编译,并链接到托管、非托管和混合库和 dll。

谁能解释一下这个问题? VS2005 和 VS2008 在这方面是否有任何已知的差异?

谢谢!

I have converted a mixed mode MFC application from VS2005 to VS2008. It is compiling OK but when starting the application I get an assert in afxwin1.inl because afxCurrentResourceHandle = NULL.

This is before MyCWinApp::InitInstance is called. The call stack is

mfc90d.dll->AfxWinInit (with HINSTANCE = NULL)
myapp.exe!InternalDllMain
myapp.exe!PostDllMain
myapp.exe!dynamic intilizer for postDllMain::A0x61ae6c8e

The same project in VS2005 starts up fine and I notice that instead of PostDllMain beeing called WinMainCRTStarup is being called and it gets a defined instance handle:

mfc80d.dll!AfxWinInit (with HINSTANCE = 0x0040000)
mfc80d.dll!AfxWinMain
myApp.exe!WinMain
myApp.exe!__tmainCRTStartup
myapp.exe!WinMainCRTStartup

The app is compiled with /clr and links to both managed, unmanaged and mixed libs and dlls.

Can anyone shed some light on this issue?
Are there any known differences in this area between VS2005 and VS2008?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静 2024-08-01 17:27:00

我在MSDN论坛上得到了张荣春很好的回答:

您好,

我这边进行了测试,并没有在我这边重现问题。 然而,Vsiaul Studio 2008中的调用堆栈看起来像是一个DLL,所以我尝试在项目设置的Proprocessor Definitions(/D“_USRDLL”)中添加_USRDLL,我得到了与您描述的相同的断言。 请检查项目是否使用“_USRDLL”编译。

更多信息
http://support.microsoft.com/kb/115088

如果这有帮助,请告诉我,如果没有,您能否向我们展示项目设置的命令行?

谢谢,
张荣春


这句话说得对!

事实证明,我的解决方案中设置为静态库的项目之一在其预处理器定义中定义了 _USRDLL。 不知何故,这在 VS2005 中被丢弃,但 VS2008 显然不喜欢它。

谢谢你先生。 张!

I got a nice answer from Rong-Chun Zhang on the MSDN forum:

Hello,

I performed a test on my side, and I didn't reproduce the problem on my side. However, the call stack in Vsiaul Studio 2008 looks like it is a DLL, so I tried add the _USRDLL in the Proprocessor Definitions(/D "_USRDLL") of the project settings, I got the same assertion as you described. Please check if the project is compiled with "_USRDLL".

More information
http://support.microsoft.com/kb/115088

Let me know if this helps, if not, could you please show us the command line of the project settings?

Thanks,
Rong-Chun Zhang


This was right on the mark!

Turns out that one of the projects in my solution which is set up as a static lib had _USRDLL defined in its preprocessor definitions. Somehow this is discarded in VS2005 but VS2008 clearly does not like it.

Thank you mr. Zhang!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文