如何确定程序异常位置
请问各位高手,我用VB.NET(vs2008)写的一个程序,其中用到了多线程,用到了外部控件等,程序总是在运行一天左右出现异常,我直接在VS2008里点调试运行也同样出现异常,我的问题是怎么确定这个异常是由哪一段代码引起的,我在每个可能引起异常的地方都写了TRY CATCH,但还是看不到出错的地方,程序异常信息如下:
线程 '<无名称>' (0xcbc) 已退出,返回值为 0 (0x0)。
在 System.AccessViolationException 中第一次偶然出现的“System.Drawing.dll”类型的异常
在 System.AccessViolationException 中第一次偶然出现的“System.Drawing.dll”类型的异常
“bjl.vshost.exe”(托管): 已加载“C:\WINDOWS\assembly\GAC_MSIL\System.Transactions.resources\2.0.0.0_zh-CHS_b77a5c561934e089\System.Transactions.resources.dll”
System.Transactions Critical: 0 : <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>未处理的异常</Description><AppDomain>bjl.vshost.exe</AppDomain><Exception><ExceptionType>System.AccessViolationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>尝试读取或写入受保护的内存。这通常指示其他内存已损坏。</Message><StackTrace> 在 System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
在 System.Drawing.SafeNativeMethods.Gdip.GdipDisposeImage(HandleRef image)
在 System.Drawing.Image.Dispose(Boolean disposing)
在 System.Drawing.Image.Finalize()</StackTrace><ExceptionString>System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
在 System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
在 System.Drawing.SafeNativeMethods.Gdip.GdipDisposeImage(HandleRef image)
在 System.Drawing.Image.Dispose(Boolean disposing)
在 System.Drawing.Image.Finalize()</ExceptionString></Exception></TraceRecord>
未处理的“System.AccessViolationException”类型的异常出现在 System.Drawing.dll 中。
其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。