【发布时间】:2015-10-27 10:33:17
【问题描述】:
我有一个最初在 VS2013 中编译的程序。现在我已经安装了 VS2015,我什至在编译我的应用程序时遇到了问题。它是用 C++/CLI 编写的。它最初针对 v120_xp 工具集。我尝试使用该目标工具集进行编译(以及我的程序使用的所有 C++ 库,它们是 GraphicsMagick 和 libsquish)。如果它针对该工具集,它甚至不会编译。所以我尝试以 v140_xp 为目标(我的程序的一些用户仍然使用 Windows XP)。那也没用。
所以我决定只针对 v140 工具集和 .NET 框架版本 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。
对正在发生的事情有任何想法吗?非常感谢任何帮助或指示。
【问题讨论】:
-
你清理并重新编译了整个项目吗?我最近也切换到 2015 并且升级我的项目后没有这样的问题。
-
第一个异常可能在内部被捕获和处理,从而导致第二个异常。
Expression: _CrtIsValidHeapPointer(block)表示内存已损坏,可能是由于写入超出缓冲区的末尾或写入超出类的末尾,因为编写器假定该类大于分配的(例如,当它期望派生类并获取基类或不同类的对象)。将异常设置更改为在最初抛出 0xC0000005 错误时停止,以便您可以看到最初的问题。 -
@KompjoeFriek 是的,我清理了整个项目并重新编译。我还重新编译了 GraphicsMagick 和 libsquish 以针对 v140 工具集,它编译得很好。
-
@1201ProgramAlarm 谢谢,我会试试的。如何更改异常设置以在引发 0xC0000005 时停止?我不太擅长调试(虽然我应该是,但这是我必须努力的事情)。
-
从调试菜单,windows 子菜单,“异常设置”。展开“Win32 异常”部分并选中 0xC0000005 异常旁边的框。
标签: .net c++-cli visual-studio-2015