您应该如何诊断错误 SEHException - 外部组件抛出异常
每当用户报告错误时,例如
System.Runtime.InteropServices.SEHException - 外部组件抛出异常?
作为一名程序员,我可以做些什么来确定原因吗?
场景:一名用户(使用我公司编写的程序)报告了此错误。 这可能是也可能不是一次性错误。他们提到,上个月,电脑已经两次“停止工作”。我从经验中学到,不要太字面地理解这个描述,因为这通常意味着与计算机相关的某人没有按预期工作。他们无法向我提供更多详细信息,我也找不到任何记录的错误。因此,可能是也可能不是这个错误。
从堆栈跟踪来看,实际的错误是在构造一个不直接调用任何互操作代码的类时出现的,但可能由于该对象可能是数据绑定到 DevExpress 网格的列表的一部分而变得复杂。
该错误被未处理的异常例程“捕获”,该例程通常会关闭程序,但可以选择忽略并继续。如果他们选择忽略该错误,则程序会继续工作,但下次运行该例程时会再次出现错误。然而,关闭并重新启动我们的应用程序后,它没有再次发生。
所讨论的计算机似乎没有受到压力。它运行的是 Vista Business,拥有 2GB 内存,根据任务管理器的数据,我们的应用程序只使用了大约一半的内存,而我们的应用程序只有大约 200Mb。
还有另一条信息可能相关,也可能不相关。同一程序的另一部分使用第三方组件,该组件实际上是本机 dll 的 dotnet 包装器,并且该组件确实存在一个已知问题,您偶尔会遇到
尝试读取或写入受保护的内存。这通常表明其他内存已损坏
组件制造商表示,这个问题已在我们内部使用的组件的最新版本中得到修复,但尚未提供给客户。
鉴于错误的后果很低(不会丢失任何工作,重新启动程序并返回到原来位置最多只需要一分钟),并且考虑到客户很快就会获得新版本(更新后的第三个版本) party 组件),我显然可以祈祷并希望错误不会再次发生。
但我还能做些什么吗?
Whenever a user reports an error such as
System.Runtime.InteropServices.SEHException - External component has thrown an exception?
is there anything that I as a programmer can do to determine the cause?
Scenario : One user (using a program my company wrote) has reported this error.
This may or may not have been a one off error. They mentioned that in the last month, the computer has twice 'stopped working'. I have learnt from experience, not to take this description too literally, as it usually means that someone relating to the computer is not working as expected. They were unable to give me more details and I could not find any logged errors. Hence it may or may not have been this error.
From the stack-trace, the actual error was when constructing a class which does not directly call any interop code, but perhaps complicated by the fact that the object may be part of a list that is databound to a DevExpress Grid.
The error was 'caught' by an unhandled exception routine which normally will close down the program, but has an option to ignore and continue. If they opted to ignore the error, then the program continued working but the error re-occurred when this routine was next run. However it did not occur again after closing and restarting our application.
The computer in question did not seem to be stressed out. It is running Vista Business, has 2GB of memory and according to Task Manager was only using about half of that with our application just about 200Mb.
There is one other piece of information that may or may not be relevant. Another section of the same program uses a third party component which is effectively a dotnet wrapper around a native dll and this component does have a known issue where very occasionally, you get a
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
The component makers say that this has been fixed in the latest version of their component which we are using in-house, but this has not been given to the customer yet.
Given that the consequences of the error are low (no work is lost and restarting the program and getting back to where they were only takes a minute at most) and given that the customer will shortly be getting a new version (with the updated third-party component), I can obviously cross my fingers and hope the error won't occur again.
But is there anything more I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
是的。此错误是一个结构化异常,未映射到 .NET 错误。可能是您的 DataGrid 映射抛出了未捕获的本机异常。
您可以通过查看 来判断发生了什么异常ExternalException.ErrorCode 属性。我会检查您的堆栈跟踪,如果它与 DevExpress 网格相关,请向他们报告问题。
Yes. This error is a structured exception that wasn't mapped into a .NET error. It's probably your DataGrid mapping throwing a native exception that was uncaught.
You can tell what exception is occurring by looking at the ExternalException.ErrorCode property. I'd check your stack trace, and if it's tied to the DevExpress grid, report the problem to them.
当我的程序第一次使用本机 dll 包装器时,我遇到了类似的 SEHException 问题。结果发现该包装器的本机 DLL 丢失了。异常对解决这个问题没有任何帮助。最终有帮助的是在后台运行 procmon 并检查加载所有必要的 DLL 时是否有任何错误。
I had a similar problem with an SEHException that was thrown when my program first used a native dll wrapper. Turned out that the native DLL for that wrapper was missing. The exception was in no way helpful in solving this. What did help in the end was running procmon in the background and checking if there were any errors when loading all the necessary DLLs.
如果您遇到本文所述的问题:
asp.net mvc 调试器抛出 SEHException< /a>
那么解决方案是:
如果您有来自 Trusteer 的任何应用程序(例如 rapport 或其他任何东西),只需卸载并重新启动系统,它就会正常工作...在这里找到了这个解决方案:
http://forums.asp.net/t /1704958.aspx/8/10?Re+SEHException+抛出+when+I+run+the+application
if you are having a problem as describe in this post:
asp.net mvc debugger throwing SEHException
then the solution is:
if you have any application from Trusteer (like rapport or anything ) just uninstall and reboot your system, it'll work fine ... found this solution here:
http://forums.asp.net/t/1704958.aspx/8/10?Re+SEHException+thrown+when+I+run+the+application
询问组件制造商如何测试客户遇到的问题是否是他们声称已在最新版本中修复的问题,而无需/在向客户部署最新版本之前。
Ask the component maker how to test whether the problem that the customer is getting is the problem which they say they've fixed in their latest version, without/before deploying their latest version to the customer.
只是另一个信息...
今天在 Windows 2012 R2 x64 TS 系统上遇到了这个问题,其中应用程序是从 unc/network 路径启动的。所有终端服务器用户的一个应用程序都会出现此问题。
在本地执行应用程序没有问题。重新启动后,它再次开始工作 - 抛出的 SEHException 是 Constructor init 和 TargetInitationException
Just another information...
Had that problem today on a Windows 2012 R2 x64 TS system where the application was started from a unc/network path. The issue occured for one application for all terminal server users.
Executing the application locally worked without problems. After a reboot it started working again - the SEHException's thrown had been Constructor init and TargetInvocationException
当应用程序驻留在网络共享上,并且在使用应用程序时设备(笔记本电脑、平板电脑等)与网络断开连接时,我遇到了此错误。就我而言,这是由于 Surface 平板电脑超出了无线范围。安装更好的WAP后就没有问题了。
I have come across this error when the app resides on a network share, and the device (laptop, tablet, ...) becomes disconnected from the network while the app is in use. In my case, it was due to a Surface tablet going out of wireless range. No problems after installing a better WAP.
我的计算机配置:
操作系统:Windows 10 版本 1703 (x64)
我在 Visual Studio 2017 社区版中调试 C# .NET 项目时遇到此错误。我通过在运行时加载的 C++ 程序集上执行 p/invoke 来调用本机方法。我遇到了 OP 报告的完全相同的错误。
经过一些分析,我发现 Visual Studio 正在使用非管理员用户帐户运行。因此,我在具有计算机管理权限的不同用户帐户下重新启动了 Visual Studio。就这样。我的问题得到了解决,我没有再遇到这个问题。
需要注意的一件事是,在 C++ 程序集上调用的方法应该在注册表中写入一些内容。我没有去调试C++代码来做进一步的分析。但我认为整个事情有可能失败,因为需要管理权限才能写入注册表。因此,早些时候,当 Visual Studio 在计算机上没有管理权限的用户帐户下运行时,本机调用会失败。
My machine configurations :
Operating System : Windows 10 Version 1703 (x64)
I faced this error while debugging a C# .NET project in Visual Studio 2017 Community edition. I was calling a native method by performing p/invoke on a C++ assembly loaded at run-time. I encountered the very same error reported by OP.
After doing some analysis, I found that Visual Studio was running with a non-admin user account. So I relaunched Visual Studio under a different user account which had administrative privileges on the machine. That's all. My problem got resolved and I didn't face the issue again.
One thing to note is that the method which was being invoked on C++ assembly was supposed to write few things in registry. I didn't go debugging the C++ code to do further analysis. But I see a possibility that the whole thing was failing as administrative privileges are required to write in registry. So earlier when Visual Studio was running under a user account without administrative privileges on the machine, then the native calls were failing.
我在对我设置的内存缓存运行单元测试时遇到此错误。它淹没了缓存。使缓存失效并重新启动虚拟机后,一切正常。
I got this error while running unit tests on inmemory caching I was setting up. It flooded the cache. After invalidating the cache and restarting the VM, it worked fine.
我只是在 if like 中遇到了这个错误:
解决了像下面这样的 try catch 中的包装问题。为什么会发生,为什么会解决,仍然是个谜:
I got this error in a mere if like:
Solved wrapping in a try catch like bellow. Why it happened, why it solved, still a mistery: