473,385 Members | 1,546 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,385 software developers and data experts.

InvalidCastException

Hey folks,

ive got the following problem:

i have a class "ClassA" that has a Collection
of "ClassB". Ive a Property for the Collection
so im able to design the Values using the Windows Forms Designer (VS2005).

But sometimes then i open the form in the designer i
get an "InvalidCastException ... dK.ClassA is not of type dK.ClassA."

Hope you understand my opinion!

Many thanks,
Dennis
May 10 '06 #1
2 1580
Are both ClassA, and the instance of ClassB that you are desiging in the
same project?

If so, this is a VS.NET bug, that my company probably spent about 4 months
going back and forth with MS about. Basically, the problem is VS.NET
loading up a copy of the DLL you are workin on into memory. Then, when there
is a change or a recompile, it loads up the new copy - and gets confused.
With this bug, it also ends up deleting a whole bunch of designer generated
code.

If what I am describing is the case for you, then the only solution is to
move out the part you are designing out to a separate project. So have
ClassA and ClassB in their own project, and the form or whatever that is
using them in a different one.

"Tyler Durden" <Ty*********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
Hey folks,

ive got the following problem:

i have a class "ClassA" that has a Collection
of "ClassB". Ive a Property for the Collection
so im able to design the Values using the Windows Forms Designer (VS2005).

But sometimes then i open the form in the designer i
get an "InvalidCastException ... dK.ClassA is not of type dK.ClassA."

Hope you understand my opinion!

Many thanks,
Dennis

May 10 '06 #2
wow many thanks!!!!!

"Marina Levit [MVP]" wrote:
Are both ClassA, and the instance of ClassB that you are desiging in the
same project?

If so, this is a VS.NET bug, that my company probably spent about 4 months
going back and forth with MS about. Basically, the problem is VS.NET
loading up a copy of the DLL you are workin on into memory. Then, when there
is a change or a recompile, it loads up the new copy - and gets confused.
With this bug, it also ends up deleting a whole bunch of designer generated
code.

If what I am describing is the case for you, then the only solution is to
move out the part you are designing out to a separate project. So have
ClassA and ClassB in their own project, and the form or whatever that is
using them in a different one.

"Tyler Durden" <Ty*********@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
Hey folks,

ive got the following problem:

i have a class "ClassA" that has a Collection
of "ClassB". Ive a Property for the Collection
so im able to design the Values using the Windows Forms Designer (VS2005).

But sometimes then i open the form in the designer i
get an "InvalidCastException ... dK.ClassA is not of type dK.ClassA."

Hope you understand my opinion!

Many thanks,
Dennis


May 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Johan Appelgren | last post by:
Hi, I'm trying to serialize a class hierarchy using System.Xml.Serialization.XmlSerializer from a class that is loaded as a Com object. But it fails with a InvalidCastException. I don't know...
1
by: bob scola | last post by:
I have a csharp, VS 2003 solution for a winform application The application uses an object called a "matter" and the class is defined in matter.cs. I can load matter objects into a combobox ...
11
by: Roy Lawson | last post by:
I have no idea what is going on here. I wrote a simple application in VB.NET to generate a Crystal Report, and I am now trying to move it to ASP.NET with Crstal Enterprise. I wish I could tell...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
0
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
8
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
8
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i trying to collect windows services. i'm getting inconsistencies. the collection works every time locally. but remote collection yields different result depending on my lab environment. 1) in...
4
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
8
by: Joe HM | last post by:
Hello - I was wondering that the "cleanest" way is to determine whether a CType() will throw an InvalidCastException? I have data I receive as an Object and I want to convert it to a String...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...

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.