C# 程序已退出,代码为 -1073610751 (0xc0020001)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18098331/
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
program has exited with code -1073610751 (0xc0020001)
提问by Panda Pajama
I'm getting a strange error on a SharpDX program I made.
我在制作的 SharpDX 程序中遇到一个奇怪的错误。
The program contains one form MainForm
, which inherits from SharpDX.Windows.RenderForm
(I'm doing Direct3D 9). I have some logic that kills the program by calling MainForm.Close()
, and it works perfectly.
该程序包含一种形式MainForm
,它继承自SharpDX.Windows.RenderForm
(我正在做 Direct3D 9)。我有一些逻辑可以通过调用来终止程序MainForm.Close()
,并且它运行良好。
However, when I close the form with the X button, or by double clicking the top left corner of the screen, the program ends with code -1073610751 (0xc0020001).
但是,当我使用 X 按钮关闭表单或双击屏幕左上角时,程序以代码 -1073610751 (0xc0020001) 结束。
This is a relatively minor annoyance, because it only happens when the program is finishing, so it doesn't really matter if it exits with an error, because it is actually finishing.
这是一个相对较小的烦恼,因为它只在程序完成时发生,所以它是否以错误退出并不重要,因为它实际上正在完成。
However, this error does not happen when I set a breakpoint at the last line of my Main()
. If I do so, and then close the window as I explained, the breakpoint gets hit, and resuming ends the program with code 0.
但是,当我在Main()
. 如果我这样做,然后按照我的解释关闭窗口,断点就会被命中,并以代码 0 结束程序。
Apart from SharpDX and one pure C DLL I am calling to one-shot process some data, I am not doing mixed code, or any other weird stuff.
除了 SharpDX 和一个纯 C DLL 我调用一次性处理一些数据,我没有做混合代码或任何其他奇怪的东西。
I've looked around, but this code appears to be related to string bindings? other people seem to have this problem when doing weird mixed C++/CLI stuff, but I'm not doing anything like that.
我环顾四周,但这段代码似乎与字符串绑定有关?其他人在做奇怪的混合 C++/CLI 东西时似乎有这个问题,但我没有做类似的事情。
Any ideas? at least on how to get more concise information on this error code?
有任何想法吗?至少如何获得有关此错误代码的更简洁的信息?
回答by Hans Passant
It is a very low-level RPC error. Which is likely to be used in your program, it is the underlying protocol on top of which COM runs. There are plenty of candidates, SharpDX itself uses the COM interop layer to make DirectX calls. And DirectX itself is very likely to make such kind of calls to your video driver.
这是一个非常低级的 RPC 错误。它可能会在您的程序中使用,它是运行 COM 的底层协议。有很多候选者,SharpDX 本身使用 COM 互操作层来进行 DirectX 调用。而且 DirectX 本身很可能对您的视频驱动程序进行此类调用。
It is also the kind of error code you'd expect to get triggered if there's a shutdown-order problem. Like using a COM interface after it was already released. Shutting down a program cleanly can be a difficult problem to solve, especially when there are lots of threads. There are in any DirectX app. It is also very easy to ignore such a problem, even if it is known and recorded in somebody's bug database. Because, as you noted, the program otherwise shuts down okay without any nasty exceptions. RPC already prevented it from blowing up, you are seeing the error code it generated.
如果出现关闭顺序问题,这也是您希望触发的那种错误代码。就像在已经发布后使用 COM 接口一样。干净地关闭程序可能是一个难以解决的问题,尤其是当有很多线程时。在任何 DirectX 应用程序中都有。忽略这样的问题也很容易,即使它是已知的并记录在某人的错误数据库中。因为,正如您所指出的,该程序在没有任何令人讨厌的异常的情况下可以正常关闭。RPC 已经阻止它爆炸,您会看到它生成的错误代码。
There's very little you can do yourself about this problem, this is code you did not write and you'll never find the programmer who did. If you see a first-chance exception notification in the Output window then you could enable the unmanaged debugger, use Debug + Exceptions and tick the Thrown checkbox for Win32 exception, enable the Microsoft Symbol server and you'll get a stack trace when the exception is thrown. Beware this will be in the bowels of native code with no source to look at. But it could pin-point the DLL that's causing the problem. Still nothing you can do to fix that DLL. I'd recommend a video driver update, the most common source of trouble. That's about as far as you can take it.
对于这个问题,你自己几乎无能为力,这是不是你写的代码,你永远找不到写的程序员。如果您在“输出”窗口中看到第一次机会异常通知,那么您可以启用非托管调试器,使用调试 + 异常并勾选 Win32 异常的抛出复选框,启用 Microsoft 符号服务器,您将在异常时获得堆栈跟踪被抛出。请注意,这将位于本机代码的内部,没有可查看的源代码。但它可以查明导致问题的 DLL。您仍然无法修复该 DLL。我建议更新视频驱动程序,这是最常见的问题来源。这就是你能承受的范围。