VS2015:迁移的项目编译,但不会运行(“Debug Assertion Failed!”)

时间:2015-08-29 23:28:13

标签: .net c++-cli visual-studio-2015

我有一个在VS2013中编译的原始程序。现在我已经安装了VS2015,我一直有问题甚至让我的应用程序编译。它是用C ++ / CLI编写的。它最初针对v120_xp工具集。我尝试使用该目标工具集(以及我的程序使用的所有C ++库,包括GraphicsMagick和libsquish)进行编译。如果它针对该工具集,它甚至不会编译。所以我尝试了针对v140_xp(我的程序的一些用户仍然使用Windows XP)。这也不起作用。

所以我决定只针对v140工具集和.NET framework 4.5.2版本(它最初的目标是4.0)。

编译成功。

但是现在我的程序甚至都没有启动。我调试它,我得到了这个:

Exception thrown at 0x77751ed2 in PathCreator.exe: 0xC0000005: Access violation reading location 0x23462c5f.
Debug Assertion Failed!

Program: ...Visual Studio 2015\Projects\PathCreator\Debug\PathCreator.exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 1037

Expression: _CrtIsValidHeapPointer(block)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
'PathCreator.exe': Loaded 'C:\Windows\syswow64\dwmapi.dll', Cannot find or open the PDB file.
PathCreator.exe has triggered a breakpoint

Exception thrown at 0x53cb6866 in PathCreator.exe: 0xC0000005: Access violation reading location 0x23462c70.
Exception thrown at 0x76d23e28 in PathCreator.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.
Additional information: The type initializer for '<Module>' threw an exception.

An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.
Additional information: The type initializer for '<Module>' threw an exception.

The program '[4156] PathCreator.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
The program '[4156] PathCreator.exe: Native' has exited with code -1 (0xffffffff).

我不知道为什么会这样。我几乎准备卸载VS2015并返回VS2013。

有关正在发生的事情的任何想法?非常感谢任何帮助或指示。

1 个答案:

答案 0 :(得分:0)

我设法通过更改我的程序的入口点来摆脱这个问题(到目前为止)。在项目的“属性”页面中,在Linker-&gt; Advanced下,我清除了“入口点”选项(它是“主要”)。然后我将我的main方法(最初由Visual Studio的早期版本定义为“int main(array ^ args)”)更改为“int WinMain(void * var1,unsigned long var2,void * var3)”。

根据VS帮助,让编译器选择入口点可以确保“...正确初始化C运行时库,并执行静态对象的C ++构造函数”。听起来像我们一直存在的问题。

我不确定这个问题是否现在出现了,因为微软不再支持托管C ++中的winforms,或者它与CRT的重新架构(或完全不同的东西)有关。我也不确定这是否是正确的解决方案,但它似乎对我正在进行的程序有效。