When you get a System.BadImageFormatException. maybe you indeed have a bad system image.

I am getting a StackOverflowException with two functions repeating on the call stack, one is the constructor of System.BadImageFormatException, another is System.Environment.GetResourceStringLocal.  Since the call that throws the stack overflow is to a web service proxy defined in the same project as the application, there isn’t a 32bit/64bit mismatch here (32bit machine with every project targeting x86), unlike almost all other discussions on the internet about this exception.

After inspecting Fusion and event logs and finding nothing suspicious, I decided to treat it as a real bad image problem and reinstalled .Net. Ура! The exception went away after reinstalling.

Sometimes, the exception name isn’t misleading.

PS a similar question was closed as too vague on stackoverflow.

One response to “When you get a System.BadImageFormatException. maybe you indeed have a bad system image.”

  1. 蒋老师,请恕我唐突,冒昧的在这里留言,我有一问题,一直找不到方案,想求助您。
    问题:
    我已经取得IE的IHTMLDocument2, 请问如何在网页内容动态更新后得到通知?
    我想在网页更新之后,得到通知,然后处理被更新的数据。

Leave a reply to JaneQin Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.