Home All Groups Group Topic Archive Search About

Debugging UserControl

Author
8 Nov 2006 8:19 PM
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

Author
8 Nov 2006 9:43 PM
Steve Long
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

Show quoteHide quote
"Steve Long" <Steve_Noneya@NoSpam.com> wrote in message
news:%23QA5qM3AHHA.3540@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
9 Nov 2006 4:57 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Steve Long" <Steve_Noneya@NoSpam.com> schreef in bericht
news:%23QA5qM3AHHA.3540@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
9 Nov 2006 4:54 PM
Steve Long
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

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23NMYIt7AHHA.5060@TK2MSFTNGP02.phx.gbl...
> 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
>
> "Steve Long" <Steve_Noneya@NoSpam.com> schreef in bericht
> news:%23QA5qM3AHHA.3540@TK2MSFTNGP03.phx.gbl...
>> 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
>>
>
>