如何检查 C# 编译器抛出的异常?
编译器失败并显示以下消息: “无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。”
我知道这与序列化有关(一旦我取消注释标记为 [OnSerialized] 的方法,构建就会失败。
我如何检查 LoaderExceptions?或者更一般地说,如何捕获和检查 C# 编译器抛出的任何异常?
The compiler failed with the following message:
"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
I know this has something to do with serialization (as soon as I uncomment a method tagged with [OnSerialized] the build fails.
How can I inspect LoaderExceptions? Or more generally speaking how can I trap and inspect any exceptions thrown by c# compiler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试在 Windbg.exe 下运行 csc.exe 并检查引发的托管异常。如果存在需要中断的特定的第一次机会异常,您可以发出
sxe
命令。然后,加载 sos.dll (.loadby sos.dll mscorwks
) 扩展并检查使用!pe
引发的异常。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
.