简体   繁体   English

如果在调试过程中更改代码(“编辑并继续”),然后执行Debug.SetNextStatement,则CLR崩溃

[英]CLR crash when code change during debugging (“Edit and Continue”) is followed by Debug.SetNextStatement

During Visual Studio 2015 debugging session (breakpoint hit), if I change almost any code and select any of Continue , Step Into , Step Over (, etc.), commands, I immediately get ExecutionEngineException followed by CLR crash. 在Visual Studio 2015调试会话期间(命中断点),如果我几乎更改了任何代码并选择ContinueStep IntoStep Over (等等),命令中的任何一个,我会立即得到ExecutionEngineException并随后出现CLR崩溃。

This seems to be appearing only in one project. 这似乎只出现在一个项目中。

System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason, int pvLoopData)    Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)    Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext context)  Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()    Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine)   Unknown
[Native to Managed Transition]  
[Managed to Native Transition]  
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) Unknown
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()   Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)    Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()    Unknown

How to troubleshoot this issue? 如何解决此问题?

I found the answer by minimalization of the problem scenario. 我通过最小化问题场景找到了答案。

It looks that problem is with combination + + and this code: 看来问题在于 + + 和以下代码的组合:

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim gridSize As Size = New Size(3, 11)
        Dim z As Integer
        z = 22
        z = 1
    End Sub
End Class

Place breakpoint at End Sub , stop at it, swap the assignments and set next statement to the first assignment. 将断点放置在End Sub ,在其处停止,交换分配并将下一条语句设置为第一个分配。 Boom. 繁荣。

Reported to the Microsoft. 向微软报告 Workaround is to use and higher. 解决方法是使用及更高版本。

I have the same problem with Visual Studio Community 2015 in C#. 我在C#中使用Visual Studio Community 2015遇到相同的问题。 When debugging a project compiled for .Net 3.5, hitting a breakpoint and doing 'edit and continue', it rarely survives. 在调试为.Net 3.5编译的项目时,遇到断点并执行“编辑并继续”操作时,它几乎无法生存。 The compiler/IDE crashes with one of several possible error messages, most often with ExecutionEngineException followed by CLR crash. 编译器/ IDE因几种可能的错误消息之一而崩溃,大多数情况下是ExecutionEngineException,然后是CLR崩溃。

When the same project is compiled to .net 4.6.1, the VS 2015 IDE debugger operates correctly. 将同一项目编译到.net 4.6.1时,VS 2015 IDE调试器将正确运行。 It is enough to set the main project to .net 4.6.1; 将主项目设置为.net 4.6.1就足够了; the .dlls called are then debuggable even when they are still .net 3.5. 这样,即使它们仍然是.net 3.5,也可以对其进行调试。

(The old VS 2013 IDE debugger operated correctly with .net 3.5, only very rarely it crashed.) (旧版VS 2013 IDE调试器可以在.net 3.5上正常运行,很少会崩溃。)

This behaviour is true for many projects. 对于许多项目来说,这种现象都是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM