在升级Boost / .NET /编译器版本后,Environment.Exit(0)挂起我的应用程序

时间:2014-12-16 17:29:01

标签: .net winforms boost c++-cli

我有一个WinForms应用程序,它使用了几个C ++ / CLI DLL,而这些DLL又与Boost链接。由于Boost或std库有些奇怪,当我正常退出这个应用程序时(甚至在它加载后)它会因为双重释放C ++语言环境方面而崩溃。为了解决这个问题,我开始使用Process.GetCurrentProcess().Kill(),但后来当我需要正常退出以获得0退出代码(即用于自动化测试)时,我转而使用Environment.Exit(0)

我刚刚将使用VS 2010编译的.NET 4和Boost 1.54的依赖项升级到使用VS 2013编译的.NET 4.5和Boost 1.56。在升级之前,Environment.Exit(0)工作正常。升级后,它会无限期挂起。当我切换回Process.GetCurrentProcess().Kill()时,它退出正常(退出代码除外)。当我让它正常关闭而没有任何解决方法时,我仍然会得到locale facet崩溃(所以我猜Boost或std C ++中的问题没有得到解决)。所以我仍然需要解决方法才能工作。

我观察到的一些奇怪的事情:

  • 当我关闭程序并挂起时,然后打开“线程”选项卡 Process Explorer中的流程,流程结束
  • 当我打开进程的Threads选项卡时,然后关闭程序,它会挂起;即使我从“线程”选项卡切换到 它保持挂起
  • 在后一种情况下,有一个线程仍在运行(或等待)。该帖子的起始地址是"!。ctor"。 InteropQonverter.dll调用一些Boost代码引起了我的注意,但我不知道它是否是一个准确的堆栈跟踪,因为这是一个发布版本。 InteropQonverter.dll显然是我的C ++ / CLI DLL之一。但它并没有使用boost :: serialization AFAIK。

任何想法导致此问题或如何解决问题?

编辑:这是来自调试版本的堆栈跟踪,它具有相同的症状。它更有意义的是它挂在我的DLL的CRT init中。它似乎抛出了一个例外,但我无法抓住它?

ntdll.dll!ZwDelayExecution()  + 0xa bytes   
KernelBase.dll!SleepEx()  + 0xb3 bytes  
ntdll.dll!RtlpExecuteHandlerForException()  + 0xd bytes 
ntdll.dll!RtlDispatchException()  + 0x38f bytes 
ntdll.dll!KiUserExceptionDispatch()  + 0x2e bytes   
KernelBase.dll!RaiseException()  + 0x3d bytes   
InteropQonverter.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 415  C
InteropQonverter.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 526 + 0x13 bytes   C
InteropQonverter.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 477 C
mscoreei.dll!000007fef8405795()     
[Frames below may be incorrect and/or missing, no symbols loaded for mscoreei.dll]  
mscoree.dll!ShellShim__CorDllMain()  + 0xe1 bytes   
mscoree.dll!_CorDllMain_Exported()  + 0x37 bytes    
ntdll.dll!LdrShutdownProcess()  + 0x1d1 bytes   
ntdll.dll!RtlExitUserProcess()  + 0x90 bytes    
mscoreei.dll!000007fef83f3067()     
mscoreei.dll!000007fef83f3300()     
mscorlib.ni.dll!000007fef706188b()  
[Managed to Native Transition]  
mscorlib.dll!System.Environment.Exit(int exitCode) + 0x7b bytes 
IDPicker.exe!IDPicker.IDPickerForm.IDPickerForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) Line 1593 + 0x7 bytes   C#

1 个答案:

答案 0 :(得分:0)

我将其追踪到"无效的字符串绑定"错误,这就是我首先添加Kill()/ Exit()调用的原因。当我按照解决方案时,我显然改变了一些东西: 0xC0020001: The string binding is invalid. - Only occurring in WPF(我在我的C ++ / ClI DLL的链接器选项中添加了/NOENTRY