Debugging UserControl

  • Thread starter Thread starter Steve Long
  • Start date Start date
S

Steve Long

Hello,
A UserControl that I'm developing is causing an InvalidCastException to be
thrown when the form, with the userControl on it, is shown. The trouble is
that I don't seem to be able to debug the exception. A dialogbox is shown
with the following information when I open the form in design mode:
The following exception occured:
InvalidCastException: Specified cast not valid.

I've put a breakpoint in the UserControl_Load event and it never hits the
breakpoint when I open the form. Can someone help me in finding out how to
track this problem down?

Thanks in advance
Steve
 
Okay, I've figured out that I can start a second instance of VS 2003 and
attach to the process of the first devenv.exe and tell the second one to
break on the type of exception that I'm getting. So, it appears that when I
try to deserialize the PropertyBag (a class that I created to serialize the
properties of the user control) that it throws the specified cast not valid
exception. Now, if I serialized with that same class (a PropertyBag object),
why wouldn't I be able to deserialize that same file into an object of that
type?

Any help out there???
Steve
 
Steve,

You should be able to set a breakpoint, even if it was in the initialize or
the loadevent from the control

Are you sure your IDE is not set to release mode?

Cor
 
Hi Cor.
I am able to set a break point in the other instance of VS. However, when I
try to deserialize the same object that I serialized, I get the Invalid Cast
Exception. It doesn't make any sense. I'm doing this same type of
serializing/deserializing in other apps and it works fine.

Steve
 
Back
Top