加了try的情况下线程中抛出未捕获的异常
一、问题描述
项目中线程中明明加了try catch 捕获异常,但是一启动就报未捕获的异常导致整个程序崩溃。
下面是windows中的错误日志。
Application: 岗亭收费.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException
at park.Booking.ReceiveEboManager.runForDev()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException
at park.Booking.ReceiveEboManager.runForDev()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
二、原因
追踪了一段时间后,通过反编译看了源代码 发现 线程中有个需要用到的实体类 不存在,导致启动时找不到对应类。程序在启动是被还原为旧的版本了。
关键点是错误日志中报了此线程中的启动错误,但是没有报线程中缺少实体的错误,所以导致追踪了很久,并且加了异常捕获也没有用。