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

Specified cast is not valid exception when moved from v1.0 to v1.1

Raj
I have a c# program in which I used cast. That worked perfectly on .Net
platform 1.0. When I moved to .Net 2003, I am getting the execption
"Specified cast is not valid". I have not made any changes to the code. Is
there any difference in project settings or something else between v1.0 and
v1.1?

Thanks in advance.
--
Raj
Jul 21 '05 #1
6 1790
Raj <Ra*@discussions.microsoft.com> wrote:
I have a c# program in which I used cast. That worked perfectly on .Net
platform 1.0. When I moved to .Net 2003, I am getting the execption
"Specified cast is not valid". I have not made any changes to the code. Is
there any difference in project settings or something else between v1.0 and
v1.1?


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Raj

pos = new AutoMath.DPositionClass();
"Jon Skeet [C# MVP]" wrote:
Raj <Ra*@discussions.microsoft.com> wrote:
I have a c# program in which I used cast. That worked perfectly on .Net
platform 1.0. When I moved to .Net 2003, I am getting the execption
"Specified cast is not valid". I have not made any changes to the code. Is
there any difference in project settings or something else between v1.0 and
v1.1?


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3
Raj <Ra*@discussions.microsoft.com> wrote:
pos = new AutoMath.DPositionClass();


In what way is that a short but complete program?

See http://www.pobox.com/~skeet/csharp/incomplete.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Raj
Jon,

Thanks for your reply. Here is a code snippet. It is not complete but it is
small.

IJDPosition, iLogicalDistPort are COM interfaces defined in VC++ idl files.
DPosoition is COM class ( an ATL object ).

AutoMath.IJDPosition pos = null;
pos = new AutoMath.DPositionClass();

iLogicalDistPort.SetCenterLocation((NozzleEntities .IJDPosition)pos); //This
throws Specified cast in not valid exception.

Why cast is needed :
The iLogicalDistPort is in defined in the idl file of
NozzleEntities VC++ project. Following is the idl file:

import "AutoMath.idl";

interface IJLogicalDistPort : IDispatch
{
[id(2), helpstring("method GetCenterLocation")] HRESULT
GetCenterLocation([out,retval] IJDPosition ** ppPosition);
[id(4), helpstring("method SetCenterLocation")] HRESULT
SetCenterLocation([in] IJDPosition * pPostion);
};

library NozzleEntities
{
coclass DistribPorts
{
[default] interface IDispatch;
interface IJLogicalDistPort;
};
}

Since the object is in the type library of NozzleEntities, the method is
expecting NozzleEntities.IJDPosition as argument.

I can only create AutoMath.DPositionClass(), since that is where my
DPosition class is implemented.

I hope the scenario is clear. If not I can provide more details. Basically
I am creating an unmanaged object and calling a method on it in managed code.

My main question is, this used to work in v1.0. I haven't make any changes
except moving to v1.1. Now I get the exception. Is there any known problem
or known solution for this problem.

Thanks,
Raj

"Jon Skeet [C# MVP]" wrote:
Raj <Ra*@discussions.microsoft.com> wrote:
I have a c# program in which I used cast. That worked perfectly on .Net
platform 1.0. When I moved to .Net 2003, I am getting the execption
"Specified cast is not valid". I have not made any changes to the code. Is
there any difference in project settings or something else between v1.0 and
v1.1?


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #5
Raj <Ra*@discussions.microsoft.com> wrote:
Thanks for your reply. Here is a code snippet. It is not complete but it is
small.


Unfortunately, that still doesn't really help me, as I still can't
reproduce the problem.

Given that it's COM stuff though, I suggest you ask in the interop
group - you're more likely to get an answer there. (I'm not
particularly hot on interop, I'm afraid.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6
Raj
Thanks for your suggestion Jon,
I will try interop.

Raj

"Jon Skeet [C# MVP]" wrote:
Raj <Ra*@discussions.microsoft.com> wrote:
Thanks for your reply. Here is a code snippet. It is not complete but it is
small.


Unfortunately, that still doesn't really help me, as I still can't
reproduce the problem.

Given that it's COM stuff though, I suggest you ask in the interop
group - you're more likely to get an answer there. (I'm not
particularly hot on interop, I'm afraid.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #7

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

Similar topics

0
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
3
by: PK9 | last post by:
I am looking for assistance in pinpointing the cause of the following exception. I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my...
2
by: Fabian | last post by:
Hi, I work with asp.net 2.0 and I have a intermittent error, only happens a few times a day. In the page I evaluate a Query String and then I get data form a database. The code snipped: ...
3
by: VB Programmer | last post by:
I am setting up forms authentication. In my code I keep getting this error. Any ideas? Error.... Server Error in '/LandOLots' Application....
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...
0
by: Alan Z. Scharf | last post by:
this question in datagrid group for several days with no repsonse. I'm hoping for an answer her because of greater activity in this group. No cross-posting intended. Thanks....
6
by: Raj | last post by:
I have a c# program in which I used cast. That worked perfectly on .Net platform 1.0. When I moved to .Net 2003, I am getting the execption "Specified cast is not valid". I have not made any...
2
by: Kashiefah | last post by:
Hi, I keep on receiving this error when I click on the edit email link from the datagrid:Specified cast is not valid. Description: An unhandled exception occurred during the execution of the...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.