Help troubleshooting System.BadImageFormatException:

狂风中的少年 提交于 2020-01-04 14:31:27

问题


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?


回答1:


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

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




回答2:


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.



来源:https://stackoverflow.com/questions/214223/help-troubleshooting-system-badimageformatexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!