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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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