[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

class convertion compilation error

hs

7/24/2003 10:08:00 AM

I have a ClassLibrary(ClassLibrary1) with 2 classes (MyClass1, MyClass2).
(one inherits a DataSet, and the other requires a DataSet in its
constructor).

My Winform project and Asp.Net Web service both reference my
ClassLibrary1.dll.

My webservice has 2 methods (one returns MyClass1, the other MyClass2).

I keep getting compilation error -

Cannot implicitly convert Cannot implicitly convert type
'TestBed.localhost.MyClass1' to 'ClassLibrary1.MyClass1'

for this line of code -

MyClass1 mc = ws.GetMyClass1(); //ws = webservice

Any Help appreciated.


2 Answers

hs

7/24/2003 10:27:00 AM

0

Found the answer. (not sure why though)
I was doing -

TestBed.localhost.Service1 ws = new TestBed.localhost.Service1();
MyClass1 mc = ws.GetMyClass1();

should be -
TestBed.localhost.Service1 ws = new TestBed.localhost.Service1();
TestBed.localhost.MyClass1 mc = ws.GetMyClass1();




"hs" <hs@nospam.syn> wrote in message
news:%23fi8otcUDHA.1004@TK2MSFTNGP12.phx.gbl...
> I have a ClassLibrary(ClassLibrary1) with 2 classes (MyClass1, MyClass2).
> (one inherits a DataSet, and the other requires a DataSet in its
> constructor).
>
> My Winform project and Asp.Net Web service both reference my
> ClassLibrary1.dll.
>
> My webservice has 2 methods (one returns MyClass1, the other MyClass2).
>
> I keep getting compilation error -
>
> Cannot implicitly convert Cannot implicitly convert type
> 'TestBed.localhost.MyClass1' to 'ClassLibrary1.MyClass1'
>
> for this line of code -
>
> MyClass1 mc = ws.GetMyClass1(); //ws = webservice
>
> Any Help appreciated.
>
>


timhuang

7/25/2003 7:36:00 AM

0

Hello,

The error message showed the reason. :-)

After adding reference the web service, the return type of ws.GetMyClass1()
is TestBed.localhost.MyClass1. It is not ClassLibrary1.MyClass1. Yes, we
know that the two classes are the same. However, for the compiler, it has
no knowledge of it. What it knows is that these two classes have the same
name but belong to different namespaces. So it feels that they are
different classes. That is why you got that error message.

Did this answer your question?

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.