调试Visual Studio C#中的SEHException(InteropServices异常) - System.Runtime.InteropServices.SEHException

时间:2017-12-03 19:45:47

标签: c# visual-studio-2017 interop

我是C#和visual studio的新手。我有一个我正在尝试运行的多线程C#应用程序。它在运行时抛出以下异常:

'MyApplication.exe' (CLR v4.0.30319: f96e1533-845f-4531-9e22-611835cc0abc): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'MyApplication.exe' (CLR v4.0.30319: f96e1533-845f-4531-9e22-611835cc0abc): Loaded 'D:\workspace\Apps\Branches\X\Applications\MyApplication\bin\Debug\GGT.Games.dll'. Symbols loaded.
System.Transactions Critical: 0 : 'MyApplication.exe' (CLR v4.0.30319: f96e1533-845f-4531-9e22-611835cc0abc): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>MyApp</AppDomain><Exception><ExceptionType>System.Runtime.InteropServices.SEHException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>External component has thrown an exception.</Message><StackTrace>   at Microsoft.Win32.Win32Native.CloseHandle(IntPtr handle)
at Microsoft.Win32.SafeHandles.SafeWaitHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Finalize()</StackTrace>
<ExceptionString>System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Microsoft.Win32.Win32Native.CloseHandle(IntPtr handle)
at Microsoft.Win32.SafeHandles.SafeWaitHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Finalize()</ExceptionString></Exception></TraceRecord>
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in mscorlib.dll External component has thrown an exception.

如果我没有错,GC Finalizer在尝试处理某些句柄时会抛出此异常。

我怎么知道它的处理方式?如果没有告诉我代码的哪一部分分配它,这个异常跟踪没有多大帮助。

有没有办法知道句柄以及代码的哪一部分分配了它?

感谢。

0 个答案:

没有答案