.net System.ExecutionEngineException 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/967044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:49:32  来源:igfitidea点击:

System.ExecutionEngineException Failure

.netexceptionexecution

提问by

I've been trying to find out more about this problem and I'm not having much luck. I keep reading that applications should not have this error come up and although that's all fine and dandy, it doesn't tell me what can cause this error to show up.

我一直在尝试了解有关此问题的更多信息,但运气不佳。我一直在读应用程序不应该出现这个错误,虽然这一切都很好,但它并没有告诉我是什么导致了这个错误出现。

I know this question is very broad as I'm sure there can be multiple causes for this error so I'll try to narrow it down a bit.

我知道这个问题非常广泛,因为我确定此错误可能有多种原因,因此我将尝试缩小范围。

I'm working in VS2003 developing an application that uses C++.NET

我正在 VS2003 中开发使用 C++.NET 的应用程序

The application uses mostly unmanaged code and little managed code (due to heavy interference by the garbage collector). So I'd rate it 95% unmanaged, 5% managed

应用程序主要使用非托管代码和少量托管代码(由于垃圾收集器的严重干扰)。所以我认为 95% 是非托管的,5% 是托管的

I've read somewhere that unstable/buggy/incorrect unmanaged code can mess up parts of the CLR memory rendering it corrupt and throwing this error.

我在某处读到不稳定/有问题/不正确的非托管代码可能会弄乱 CLR 内存的一部分,使其损坏并引发此错误。

Since 95% of the application is unmanaged, I'm not sure where to start looking. Maybe the few classes that interact between managed and unmanaged? What about marshalling data from managed to unmanaged? Can a bad null pointer cause this failure? What other problems can cause this? Array Index out of bounds? What about a Null Object?

由于 95% 的应用程序是非托管的,我不知道从哪里开始寻找。也许在托管和非托管之间交互的少数类?如何将数据从托管编组到非托管?错误的空指针会导致此失败吗?还有哪些其他问题会导致这种情况?数组索引越界?空对象呢?

Any information/paper/article that can give a nice list of possible causes for the System.ExecutionEngine failure would be appreciated!

任何可以提供 System.ExecutionEngine 故障的可能原因的详细列表的信息/论文/文章都将不胜感激!



Based on answers this exception can be caused in multiple scenarios, mentioning htem in answer for better visibility.

根据答案,此异常可能在多种情况下引起,在答案中提及 htem 以获得更好的可见性。

List of possible causes/scenarios -

可能的原因/场景列表 -

Possible workarounds/solutions -

可能的解决方法/解决方案 -

回答by Dani?1

This should not be taken too seriously, but I managed to get this exception while having some fun with reflection:

这不应该太当真,但我在享受反思的同时设法得到了这个例外:

typeof(IntPtr).GetField("Zero").SetValue(null, new IntPtr(666));

回答by Ann

Had the same problem - my bug turned out to be an argument mismatch between my C# code and my C++ native dll. I had added an argument to the C++ function and failed to add it to the C# side.

有同样的问题 - 我的错误结果是我的 C# 代码和我的 C++ 本机 dll 之间的参数不匹配。我已经向 C++ 函数添加了一个参数,但未能将其添加到 C# 端。

回答by Dave

I encountered it when calling a function in an unmanaged library when my managed code was compiled for release. The error goes away when compiled for debugging.

当我的托管代码编译发布时调用非托管库中的函数时,我遇到了它。编译用于调试时错误消失。

回答by Alexandre Brisebois

Quoted from the MSDN reference page for System.ExecutionEngineException:

引自MSDN 参考页面System.ExecutionEngineException

The exception that is thrown when there is an internal error in the execution engine of the common language runtime. This class cannot be inherited.

There is no non-obsolete alternative to ExecutionEngineException. If further execution of your application cannot be sustained, use the FailFast method.

Tip

In some cases, an application that targets the .NET Framework may throw an ExecutionEngineException exception during garbage collection when an application or the system on which it is running is under a heavy load. In this case, To work around this issue, you can disable concurrent garbage collection by modifying the application's configuration file. For more information, see How to: Disable Concurrent Garbage Collection.

公共语言运行库的执行引擎出现内部错误时抛出的异常。这个类不能被继承。

ExecutionEngineException 没有非过时的替代方案。如果您的应用程序无法继续执行,请使用 FailFast 方法。

提示

在某些情况下,当应用程序或运行它的系统负载过重时,面向 .NET Framework 的应用程序可能会在垃圾回收期间引发 ExecutionEngineException 异常。在这种情况下,要解决此问题,您可以通过修改应用程序的配置文件来禁用并发垃圾收集。有关更多信息,请参见如何:禁用并发垃圾收集

回答by Jimtronic

回答by Brian Kennedy

I am getting this ExecutionEngineExceptionwhen just using standard .NET Clipboard calls. My code is 100% managed. So, it seems the .NET Framework has issues.

我在ExecutionEngineException使用标准的 .NET Clipboard 调用时得到了这个。我的代码是 100% 管理的。因此,.NET Framework 似乎存在问题。

PastedData = Clipboard.GetDataObject();
object imageObj = PastedData.GetData(dataType);

where data type is "EnhancedMetafile", which was in the list of formats on the Clipboard.

其中数据类型是“ EnhancedMetafile”,它在剪贴板上的格式列表中。

回答by juFo

update your application to .net 4.0 OR 4.5 because that exception is obsolete. "Note: This API is now obsolete." see: http://msdn.microsoft.com/en-us/library/system.executionengineexception(v=vs.100).aspx

将您的应用程序更新到 .net 4.0 或 4.5,因为该异常已过时。“注意:此 API 现在已过时。” 请参阅:http: //msdn.microsoft.com/en-us/library/system.executionengineexception(v=vs.100).aspx

回答by stakx - no longer contributing

Although this thread is by now fairly old, I'll mention my own incident with this exception. I've come across it while developing a ArcGIS extension, written with VB.NET (Visual Studio 2005). ArcGIS relies heavily on the COM technology, therefore .NET-COM interop is involved. I haven't found the cause of the exception until now, but I suppose it might have to do with a building-up of un-released COM object instances, since the exception only ever occurs after the software has been crunching geometries and numbers for some time.

虽然这个线程现在已经很老了,但我会提到我自己的事件,但这个例外。我在开发用 VB.NET (Visual Studio 2005) 编写的 ArcGIS 扩展时遇到了它。ArcGIS 严重依赖于 COM 技术,因此涉及到 .NET-COM 互操作。直到现在我还没有找到异常的原因,但我想它可能与未发布的 COM 对象实例的构建有关,因为只有在软件处理几何图形和数字之后才会发生异常一段时间。

回答by Brent

I recently discovered that using the stdinstruction in assembler to set the direction flag without clearing it when you're done (cld) can cause this error. I'm using .Net 4.0.

我最近发现使用std汇编程序中的指令设置方向标志而不在完成时清除它 ( cld) 会导致此错误。我正在使用 .Net 4.0。

回答by Orion Edwards

Honestly, the only time I've ever seen this exception is when I was using the Compuware DevPartner tools to do some profiling and code analysis. DevPartner hooks deep into the core of the CLR to do it's work, but it's full of bugs, so screws the CLR up. I had to reboot my machine (and remember to never click the DevPartner toolbar buttons ever again) to get things to go back to normal.

老实说,我唯一一次看到这种异常是在我使用 Compuware DevPartner 工具进行一些性能分析和代码分析时。DevPartner 深入到 CLR 的核心来完成它的工作,但它充满了错误,所以把 CLR 搞砸了。我不得不重新启动我的机器(记住永远不要再点击 DevPartner 工具栏按钮)才能让事情恢复正常。

If you're not using devpartner, then you most likely have some unmanaged code which is trashing some memory used by the CLR. I'd advise first doing a reboot, and then trying to track down whichever bug you have which is trashing the memory. Look for buffer overruns, writing to uninitialised pointers, and all the other usual suspects.

如果您不使用 devpartner,那么您很可能有一些非托管代码,这些代码会破坏 CLR 使用的一些内存。我建议首先重新启动,然后尝试追踪破坏内存的任何错误。查找缓冲区溢出、写入未初始化的指针以及所有其他常见的可疑情况。