By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,238 Members | 1,485 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,238 IT Pros & Developers. It's quick & easy.

Debugging UserControl

P: n/a
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
Nov 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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 Long" <St**********@NoSpam.comwrote in message
news:%2****************@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

Nov 8 '06 #2

P: n/a
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" <St**********@NoSpam.comschreef in bericht
news:%2****************@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

Nov 9 '06 #3

P: n/a
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

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@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" <St**********@NoSpam.comschreef in bericht
news:%2****************@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


Nov 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.