Tracking exception source during layout of user defined controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a C# user defined control that I want to place in a form. When I
drag it into the form it generates an exception (it works okay if I add the
control manually in the code, compile and then run it ... i.e. it doesn't
generate an exception). I'd really like to use debugging tools (rather than
a time-consuming brute force approach) to discover where the exception is
occuring when I drag the control into the form, but there does not appear to
be any debugging support of this kind in VS .Net to allow this.

Any suggestions as to how to find exceptions that occur during layout but
not at runtime?

Thanks in advance.

-&&
 
Your most likely exceptions are not having a default constructor, in some
cases dragging the control from the same project it is defined in, or you
are accessing certain properties that aren't available at design-time. A great
example is that invoke calls can't be made at design time (which I think
means you Handle isn't available).
 
After you build your control, start another instance of Visual Studio
opening a test project using your control. Then attach the debugger to that
second instance of Visual Studio using the Debug/Processes menu item. If you
do this often, you may wish to change the debug start up type of your
project to Program, select the devenv.exe executable as the startup program,
and pass in the command line the path of a test project.

You don't need a separate test project; you can actually load the exact same
project in a new VS instance.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
Back
Top