473,394 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Debugging UserControl

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
3 1151
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
2
by: Just Me | last post by:
I have a large Usercontrol that I just converted from VB6 (so I'm not surprised there are bugs in it.) When I try to add an instance to a form I get an exception occurred trying to create and...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
1
by: | last post by:
How do you debug the design time behavior of user controls? I have code in the controls resize event and I've flagged a break point, but the code never breaks when I play with the control on the...
2
by: Jeff | last post by:
hi asp.net 2.0 vista business 32bit I have placed a break point with the Page_Load event of a UserControl. The break point wasn't triggered.. I have also put Debug.WriteLine("Page_Load"); in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.