Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to solve "The format of the file 'devenv.exe' is invalid" blank white page exception at design time

0.00/5 (No votes)
26 May 2003 1  
Shows how to find the exception that kills the designer

Introduction

Often if you work with inheritance with System.Windows.Forms or use third party stuff (preferred where you do not have the source) and hit Shift+F7 (View Designer), a blank white page is the only thing the designer is able to show. Normally you're confused, don't know where to start searching for this unexpected feature of VS.NET Designer. Maybe it could be the last lines of code you added today, or it could be code that nobody remembers, 'cause it was written last month from a external worker. What to do know? You should check in your code running in a few hours ?

Background

It's my job to write the UI front end library for the company i work today. There are 5 team members, which have to use my code. Every time the designer shows a white blank page, my name is called and i have to (try) fix it as fast as possible, not nice if you don't where to search the bug.

Solution Configuration

Visual Studio supports different Solution Configurations (sc), debug and release are the default ones. 'Cause we're able to add/delete this sc, we're able to add a new sc which supports design time debugging. If you're able to debug the design time, you're able to find the exception that killed the designer, you remember, blank white page.

  • Right click your solution and choose the Configuration Manager... context menu item.
  • In the "Configuration Manager" choose <New>.
  • Specify a name for your new solution configuration.
  • Hit Ok twice, the created sc is now selected.
  • Right click your project and choose "Properties" context menu item
  • The well known project property pages are now open, select Configuration Properties\Debugging
  • Switch Debug Mode to Program.
  • Let Start Application point to your devenv.exe file. See also

screenshots are available here (animated gif which opens in new window).

Exceptions

Now hit Ctrl + Alt + E, or choose Exceptions under main menu Debug\Exceptions. Because we don't know exactly which exception type we're trying to find, we best choose Break into debugger for the Common Language Runtime Exceptions. After playing around with the white blank page problem I know that System.BadImageFormatException is thrown.

Bust it

The good news is that you're now ready to bust those tricky exceptions which kicks our designer. The bad news is that the designer does not work proper cause there are exceptions in our code. We did something, that is not valid in design time, but will executed there. Or there is another exception of certain kind, also not valid for design time.

  • Hit F5 to start debugging, as you expected Visual Studio starts another Visual Studio instance where you will
  • Open the same solution you just prepared for design time debugging.
  • View the form in design mode that normally cause the designer to fall.
  • Behind your current Visual Studio should appear the well known exception dialog, hit Break and you see the code thrown it.
  • Repeat this steps until you're code is exception free (illusion), but sure till the designer work proper.

   

The demo application gives you a good sample, if you try to load form2 in designer, he crashes. Please make sure that the path to the devenv.exe reflects your current installation, otherwise the debug mode will not work proper.

Conclusions

  • I hope with this knowledge you could solve your design time problems, for my own it does.

History

  • 27.05.2003 final release

Have fun with it...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here