VS2015:迁移项目编译,但不能运行(QUOT;调试断言失败"!)断言、项目、QUOT

2023-09-06 10:18:18 作者:被拖走的真心

我有一个程序,就是原来在VS2013编译。现在,我已经安装了VS2015,我一直有,甚至让我的应用程序编译的问题。这是写在C ++ / CLI。它最初瞄准的v120_xp工具。我试着用有针对性的工具集编译(连同所有C ++库我的程序使用,这是GraphicsMagick工具和libsquish)。它甚至不会编译,如果它的目标的工具。所以,我想针对v140_xp(我的几个程序仍在使用Windows XP的用户)。这也不起作用。

I have a program that was original compiled in VS2013. Now that I have VS2015 installed, I have been having issues even getting my application to compile. It is written in C++/CLI. It originally targeted the v120_xp toolset. I tried compiling with that targeted toolset (along with all C++ libraries my program utilizes, which are GraphicsMagick and libsquish). It wouldn't even compile if it targeted that toolset. So I tried targeting v140_xp (a few of the users of my program still use Windows XP). That didn't work either.

所以,我决定只针对V140工具,和.NET Framework 4.5.2版本(它最初的目标4.0)。

So I decided to just target the v140 toolset, and .NET framework version 4.5.2 (it originally targeted 4.0).

它编译成功。

但现在我的程序甚至不会启动。我调试它,我得到这样的:

But now my program won't even start up. I debug it and I get this:

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。

I have no idea why this is happening. I'm almost ready to just uninstall VS2015 and go back to VS2013.

这是怎么回事任何想法?任何帮助或指针是极大的AP preciated。

Any ideas on what is going on? Any help or pointers are greatly appreciated.

推荐答案

我设法通过改变入口点到我的计划,以摆脱这个问题(至今)的。在项目的属性页,在连接器 - >高级,我清除了切入点选项(这是主)。然后,我改变了我的主要方法(最初由Visual Studio的早期版本定义为INT主(阵列^参数)),以诠释的WinMain(无效* VAR1,无符号长VAR2,无效* VAR3)。

I managed to get rid of this problem (so far) by changing the entry point to my program. In the project's Properties page, under Linker->Advanced, I cleared the "Entry Point" option (it was "main"). I then changed my main method (originally defined by an earlier version of Visual Studio as "int main(array ^args)") to "int WinMain(void *var1, unsigned long var2, void *var3)".

根据该VS帮助,让编译器的入口点允许它以确保...... C运行时库正确初始化,C ++构造函数静态对象执行。听起来我们一直有这个问题。

According to the VS Help, letting the compiler choose the entry point allows it to make sure "...the C run-time library is initialized correctly, and C++ constructors for static objects are executed". Sounds like the problem we've been having.

我不知道这个问题是否被显示出来了,因为微软不支持在托管C ++的WinForms了,或者是做与CRT他们rearchitecture(或完全不同的东西)。我也不能肯定这是否是正确的解决方案,但它似乎已经工作了我的工作,目前该程序。

I'm not sure whether this problem is showing up now because Microsoft doesn't support winforms in managed C++ anymore or it it is to do with their rearchitecture of the CRT (or something completely different). I'm also not sure whether this is THE correct solution but it seems to have worked for the program I'm working on at the moment.