Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / Visual Basic
Article

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

Rate me:
Please Sign up or sign in to vote.
4.43/5 (7 votes)
26 May 2003CPOL3 min read 90.7K   477   24   10
Shows how to find the exception that kills the designer

Image 1

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.

Image 2

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.

    Image 3

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Switzerland Switzerland
My interest is in the future because I am going to spend the rest of my life there. (Charles Kettering)

Biography

  • 1996 - 1998 PC Board PPL, HTML, DHTML, Javascript and ASP
  • 1999 - 2001 coding Centura against Sql Database (SqlBase,MSSQL,Oracle)
  • 2002 - 2004 C# Windows Forms
  • 2005 - 2006 C# ASP.NET, Windows Forms
  • 2006 - 2009 C#, WCF, WF, WPF
  • 2010 - 2012 C#, Dynamics CRM, Sharepoint, Silverlight
  • 2013 - 2013 C#, WCF DS (OData), WF, WPF
  • 2014 - 2016 C#, Azure PaaS, Identity, OWIN, OData, Web Api
  • 2017 - now C#, aspnet.core, IdentityServer4, TypeScript & Angular @ Azure IaaS or PaaS

Interests

  • family & friends
  • chilaxing ,)
  • coding

Comments and Discussions

 
GeneralNice tip, slight typo Pin
Richard Deeming30-May-03 7:02
mveRichard Deeming30-May-03 7:02 
GeneralRe: Nice tip, slight typo Pin
Chris Richner30-May-03 7:52
Chris Richner30-May-03 7:52 
GeneralThanks!! Pin
rahtrow29-May-03 2:44
rahtrow29-May-03 2:44 
GeneralRe: Thanks!! Pin
Chris Richner29-May-03 8:24
Chris Richner29-May-03 8:24 
GeneralAnother way route to debugging devenv Pin
Lee Alexander28-May-03 23:03
Lee Alexander28-May-03 23:03 
GeneralRe: Another way route to debugging devenv Pin
Chris Richner29-May-03 8:26
Chris Richner29-May-03 8:26 
GeneralRe: Another way route to debugging devenv Pin
Lee Alexander29-May-03 22:18
Lee Alexander29-May-03 22:18 
GeneralRe: Another way route to debugging devenv Pin
PhallGuy3-Jun-03 10:52
PhallGuy3-Jun-03 10:52 
GeneralVS.NET dumps stack traces in outputdebugstring Pin
nidhogg27-May-03 22:01
nidhogg27-May-03 22:01 
GeneralRe: VS.NET dumps stack traces in outputdebugstring Pin
Chris Richner28-May-03 0:01
Chris Richner28-May-03 0:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.