[lnkForumImage]
TotalShareware - Download Free Software

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


 

DalePres

6/12/2004 4:10:00 AM

When I pass a class to a web service as a method parameter, or from the web
service as a return value, I get an error to the effect that .Net cannot
implicitly convert from WebService.MyClass to MyLocalNamespace.MyClass
(substitute usable names). I have set references to MyClass on both the
webforms project and on the web services project and the associated DLL
exists in both projects.

Of course, explicitly casting doesn't help so I have, on small projects,
actually created the server object on the local client. That works pretty
well, but that leads to my main question.

I have a web service, myService, which has a reference to MyClass. I
create, on the webform:

myService.MyClass myClass = new myService.MyClass();

Then I set properties:

myClass.Name = "something";
myClass.Number = 234;

etc.

Each time I set or get a property, does it include a roundtrip to the server
for the definition or is the definition of the MyClass object stored locally
when I created it locally?

The other-than-main question is: Does anyone know a better way to do it?

Thanks in advance,

Dale


1 Answer

DalePres

6/13/2004 11:30:00 PM

0

Well, I have searched the net, MSDN, and the newsgroups more (for weeks now
really) and still no clear cut examples or descriptions of how to pass a
custom class as a parameter to a WebMethod or receive a custom class as a
return value from a WebMethod. Every article or newsgroup response I was
able to find speaks only in theoretical terms with no specifics or examples.

I finally managed to piece together enough little pieces that I was able to
work it through and produce a working example. I have documented it at
http://www.dalepreston.com/programming/SharedCl... including source
code.

This is basic so far but for many of us, if we have enough to get started,
we can figure the rest out for ourselves.

I hope this will help others who are working through the same thing.

Dale

"DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
news:us9jvKCUEHA.3512@TK2MSFTNGP12.phx.gbl...
> When I pass a class to a web service as a method parameter, or from the
web
> service as a return value, I get an error to the effect that .Net cannot
> implicitly convert from WebService.MyClass to MyLocalNamespace.MyClass
> (substitute usable names). I have set references to MyClass on both the
> webforms project and on the web services project and the associated DLL
> exists in both projects.
>
> Of course, explicitly casting doesn't help so I have, on small projects,
> actually created the server object on the local client. That works pretty
> well, but that leads to my main question.
>
> I have a web service, myService, which has a reference to MyClass. I
> create, on the webform:
>
> myService.MyClass myClass = new myService.MyClass();
>
> Then I set properties:
>
> myClass.Name = "something";
> myClass.Number = 234;
>
> etc.
>
> Each time I set or get a property, does it include a roundtrip to the
server
> for the definition or is the definition of the MyClass object stored
locally
> when I created it locally?
>
> The other-than-main question is: Does anyone know a better way to do it?
>
> Thanks in advance,
>
> Dale
>
>