"Raj Chudasama" <raj@asteriasgi _spamkiller.com > wrote in message news:O0******** *****@TK2MSFTNG P15.phx.gbl...
i have an app that uses a lot of bitmaps, associated with various classes etc on the gui. Everytime i open then designer i am
getting a "object reference not set to an instance of an object" msg box. i know what it measn but have no clue where it is comming
from.
how can i debug this?
With your original project open in Visual Studio .NET, switch to any tab
(for instance, a ".cs" source file tab) that's not the Designer panel.
Then open a second instance of Visual Studio .NET (so you have two
IDEs open at once). Load any debug project into this instance (for
example, your project for the designer code that's throwing the
exception) so you'll have source code when you enter the debugger.
In the second instance, choose to Debug | Attach to Process... and
hook yourself to the first "devenv.exe " (you can tell them apart by
the title bar caption). Then under Debug choose Exceptions ... and
turn on "Break into the debugger" for the System.NRE (and any
others you may be interested in). The dialog should show a red
globe with an X through it, when breaking on that Exception has
been enabled.
Task-switch back into your first instance of Visual Studio .NET and
change tabs to the Designer panel where you are receiving this "Object
not set to an instance of an object." error. If all worked correctly,
then you should be swapped back into the second instance with the
debugger on the line of source code throwing the NRE (provided
you have that debug builder of the designer and source code matching
what's loaded into the first instance -- you have to make sure your
versions/builds are the same for this to work.)
If the exception came from within Visual Studio .NET, you may only
be able to get "Disassembl y," in which case you usually want to F5
to let the designer run further. It may rethrow types of Exceptions
different from the original type that caused the fault (for this reason,
it's usually a good practice to turn on "Break into the Debugger" on
all CLR Exceptions, although some first-chance exceptions may be
a matter of routine and no cause for alarm) that will eventually bubble
up to your Designer's code.
Derek Harmon