如何检查c#编译器抛出的异常?

时间:2022-10-30 08:59:52

The compiler failed with the following message: "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

编译器在以下消息中失败:“无法加载一个或多个请求类型。获取loaderexception属性以获取更多信息。

I know this has something to do with serialization (as soon as I uncomment a method tagged with [OnSerialized] the build fails.

我知道这与序列化有关(当我取消对[onserialize]标记的方法进行注释时,构建失败)。

How can I inspect LoaderExceptions? Or more generally speaking how can I trap and inspect any exceptions thrown by c# compiler?

如何检查loaderexception ?或者更一般地说,如何捕获和检查c#编译器抛出的任何异常?

1 个解决方案

#1


1  

You could try running csc.exe under windbg.exe and inspect the managed exceptions getting thrown. If there's a particular first chance exception that you need to break on, you can issue the sxe <exception> command. Then, load the sos.dll (.loadby sos.dll mscorwks) extension and inspect the exception getting thrown with !pe.

你可以试试运行csc。exe windbg之下。执行并检查抛出的托管异常。如果需要中断某个特定的第一次机会异常,可以发出sxe 命令。然后,加载sos。dll(。loadby sos。(dll mscorwks)扩展并检查抛出的异常!

#1


1  

You could try running csc.exe under windbg.exe and inspect the managed exceptions getting thrown. If there's a particular first chance exception that you need to break on, you can issue the sxe <exception> command. Then, load the sos.dll (.loadby sos.dll mscorwks) extension and inspect the exception getting thrown with !pe.

你可以试试运行csc。exe windbg之下。执行并检查抛出的托管异常。如果需要中断某个特定的第一次机会异常,可以发出sxe 命令。然后,加载sos。dll(。loadby sos。(dll mscorwks)扩展并检查抛出的异常!