Solved

Object type cannot be converted to target type.

Posted on 2004-10-12
5
1,068 Views
Last Modified: 2007-12-19
Hello

I receive 4 of the same errors in the task pane (with a form icon to the left of the below text)

Object type cannot be converted to target type.

When I double click this, the code view opens and the cursor points at the very top of the file.

Note the project compiles with 0 errors and warnings, but I would like to know how to get rid of these errors in the task pane. Where to start debugging such a problem?
0
Comment
Question by:auk_ie
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
tinchos earned 150 total points
ID: 12292044
The problem you're having is that you're trying to cast an object to a type that cannot be casted to.

What you should do is debug your program and when you get to the part where it throws that exception
watch what is the type of the object you're casting and check if it is the same as the type you want to convert to.

Hope this helps

Tincho
0
 

Author Comment

by:auk_ie
ID: 12292792
Do you mean run the program in debug mode. I have tried that but it doesn't throw any exceptions.

If thats not what you mean, can you ellaborate.

Also I don't understand why when I click on any of the four errors, the cursor points me to the top of the file

i.e.
using System;

and not the error in question. What dous that form icon beside the error mean?
0
 
LVL 9

Expert Comment

by:tinchos
ID: 12293005
Sorry, but then, when are you receiving the errors?
when you compile it?

Tincho
0
 
LVL 10

Assisted Solution

by:Hans Langer
Hans Langer earned 100 total points
ID: 12293330
Do you use Control Version ?
Maybe the File is Read-Only
0
 

Author Comment

by:auk_ie
ID: 12293763
Yes its very strange

I think this error had something to do with crystal reports 9 that I installed after installing VS .nwt 2003 which came with v 10. But any way it's gone now after me verifying DB in the designer.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question