调试器的奇怪行为需要使用使用托管兼容模式 [英] Strange behaviour with Debugger that requires use of Use Managed Compatibility Mode

查看:572
本文介绍了调试器的奇怪行为需要使用使用托管兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2015中遇到了一个相当奇怪的行为。 我有一个C#应用程序,我知道它几个月前工作正常。 本周我需要做一些改变。 所以我重新编译了应用程序,并在使用"Debug / Start Debugging"运行
时按下面的方法:

I have encountered a rather strange behaviour with Visual Studio 2015.  I have a C# application which I know was working fine a few months ago.  This week I needed to make some changes.  So I recompiled the application and when running it using "Debug/Start Debugging" on hitting the following method:

public static void DoEvents()
{ 
    Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new EmptyDelegate(delegate { }));
}
private delegate void EmptyDelegate();

我得到以下异常:

PresentationFramework.dll中出现"System.InvalidOperationException"类型的异常未在托管/本地边界之前处理



附加信息:无法设置可见性或在窗口关闭后调用Show,ShowDialog或WindowInteropHelper.EnsureHandle。

An exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll and wasn't handled before a managed/native boundary

Additional information: Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.

另一方面,如果我使用"Debug / Start Without Debugging"运行程序。该程序与过去一样完美。 在调试模式下,如何使程序正常工作的唯一方法是设置选项"使用托管兼容性
模式"。

If on the other hand I run the program using "Debug/Start Without Debugging" the program works perfectly as in the past.  The only way how I could make the program work properly in debugging mode is to set the option "Use Managed Compatibility Mode."

我确实有部分应用程序使用C ++非托管代码,但过去我没有遇到这个问题。 肯定有一些Windows / Visual Studio更新破坏了什么。

I do have sections of the application with C++ unmanaged code, but in the past I did not have this problem.  There must have been some Windows/Visual Studio update that broke something.

有什么想法吗?

推荐答案

你好Victor Buttigieg,

Hi Victor Buttigieg,

正如你之前说过的那样,你有没有改变VS2015版本,比如更新包或调试设置除了你身边的代码?

As you said that it worked well before, do you change the VS2015 version like update package or the debugging settings except the code in your side?

请同时检查它是否与项目属性相关 - >> Debug->启用本机代码调试。

Please also check that whether it is related to the project property->Debug-> Enable native code debugging.

还请禁用"当异常跨越AppDomain或托管/本机边界时断开(仅管理)"和
"启用我的代码"工具 - > ;选项 - >调试>一般。

Please also disable "Break when exceptions cross AppDomain or managed/native boundaries (Managed only)" and "Enable Just My Code" under Tools->Options->Debugging > General.

参考:

https://开头social.msdn.microsoft.com/Forums/vstudio/en-US/79a7b495-118d-4fd6-8b9e-be51379dfbd2/visual-studio-2012-is-stopping-on-exceptions-when-all-the-settings-tell- it-not-to?forum = visualstudiogeneral

最好的问候,

杰克


这篇关于调试器的奇怪行为需要使用使用托管兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆