帮助解决 System.BadImageFormatException:

发布于 2024-07-06 17:22:16 字数 426 浏览 6 评论 0 原文

在通过联系本地 Web 服务的 .NET 3.5 SP1 项目进行调试时,我收到了异常

System.BadImageFormatException: "Bad Class Token"

当然,关于导致异常的原因并没有更多详细信息。

我可以看出发生这种情况的方法(与调用者位于同一类中),调试器无法到达。 此异常发生在调用联系 Web 服务的方法时。 我确实有其他与网络服务通信的方法,所以参考是很好的。

我对该方法的单元测试也因相同的异常而失败。
更正:我对该方法的单元测试是成功的,这进一步加剧了混乱。

有谁知道如何追踪此异常? 我已通读有关异常类的文档,这使我相信其中一个程序集的版本不正确,或者构建存在问题。

您建议采取哪些其他步骤来解决此异常问题?

While debugging through a .NET 3.5 SP1 project which is contacting a local web service, I'm receiving the exception

System.BadImageFormatException: "Bad Class Token"

Of course there aren't much more details about what's causing the exception.

I can tell that the method where this occurs, which is in the same class as it's caller, the debugger fails to reach. This exception occurs on the call of the method that contacts the web service. I do have other methods communicating with the web service, so the reference is good.

My unit tests for the method are also failing with the same exception.
Correction: my unit tests for the method are successful, furthering the confusion.

Does anyone know of a way to track down this exception? I've read through the documentation on the exception class, which leads me to believe that one of the assemblies is incorrect in its version, or there's an issue with the build.

What other steps would you suggest in troubleshooting this exception?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命硬 2024-07-13 17:22:16

在程序集上运行 peverify.exe 可能会产生有用的诊断信息。

http://msdn.microsoft.com/en-us/library/62bwd2yd。 ASPX

Running peverify.exe on the assembly may yield useful diagnostics.

http://msdn.microsoft.com/en-us/library/62bwd2yd.aspx

奢华的一滴泪 2024-07-13 17:22:16

事实证明,我得到这个异常是由于 MSTest 中的一些异常。 切换到 xUnit.net 之后一切都很好。

It turns out that I was getting this exception due to some abnormality in MSTest. Switched over to xUnit.net and everything has been fine since.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文