Serialization and Shared Interfaces

J

jehugaleahsa

Hello:

I have a Serializable class that I pass to clients via web services.
In the web service, the class implements a shared interface. The
clients also use the interface. The web reference automatically
creates an class on the client, but it doesn't implement the
interface. This means that I have to implement another class that
implements the interface, which I build from the web service class. So
I always have to convert one to the other every time I call the web
service.

Is there are way to make the automatically generated class implement
the interface?

Thanks,
Travis
 
B

Bob Powell [MVP]

Why not simply implement your concrete class as a DLL and distribute that to
the client machines. Then you only need to write the implementation once.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
J

jp2msft

Mr. Powell:

I have a question I posted the day before entitled "Deploying with DLLs."

I have not received a response, and I was hoping you might know something
about this, being an [MVP] and because you just suggested this to the OP.

How do I deploy a Windows Form application that includes DLLs? Someone has
told me that I need to specify my DLLs in the app.config so that the .Net
Framework would not block it as a security issue, but he wasn't able to tell
me how to do this.

I have found the MSDN "Runtime Settings Schema" online, but I don't know
what I should do to impliment it.

Any help or pointers would be appreciated.
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello:

I have a Serializable class that I pass to clients via web services.
In the web service, the class implements a shared interface. The
clients also use the interface. The web reference automatically
creates an class on the client

If this class is the same it will have declared that it implements the
interface so you can simply cast the instance to the interface without
any problem
 
I

Ignacio Machin ( .NET/ C# MVP )

Mr. Powell:

I have a question I posted the day before entitled "Deploying with DLLs."

I have not received a response, and I was hoping you might know something
about this, being an [MVP] and because you just suggested this to the OP.

How do I deploy a Windows Form application that includes DLLs? Someone has
told me that I need to specify my DLLs in the app.config so that the .Net
Framework would not block it as a security issue, but he wasn't able to tell
me how to do this.

I have found the MSDN "Runtime Settings Schema" online, but I don't know
what I should do to impliment it.

Any help or pointers would be appreciated.









- Show quoted text -

Hi,

What kind of dlls ?
If you want to include a DLL in the setup just add the dll in the
deployment project and ready.
I have a solution where the "main" content of the setup project is the
output of a win app that seats in the same solution, but at the same
time I add a couple of DLLs that do not form part of the win app but
that it load dynamically.
 
P

Pavel Minaev

I have a Serializable class that I pass to clients via web services.
In the web service, the class implements a shared interface. The
clients also use the interface. The web reference automatically
creates an class on the client, but it doesn't implement the
interface. This means that I have to implement another class  that
implements the interface, which I build from the web service class. So
I always have to convert one to the other every time I call the web
service.

Is there are way to make the automatically generated class implement
the interface?

No. If you look at the contract of your Web service, you'll see that
there is no information there that could be used to derive information
about things such as interface implementations for the automatic class
generator to use. It's just the way Web services work. If you want
this sort of thing, you'll have to give your DLL with the class
implemented the way you want to the clients.
 
J

jehugaleahsa

If this class is the same it will have declared that it implements the
interface so you can simply cast the instance to the interface without
any problem

When you return classes from a web service they are serialized into
SOAP. The requesting source only sees the properties and has no idea
about subclasses, interfaces or anything like that. If I was just
serializing, it wouldn't make a bit of difference. I was hoping there
was a way to tweak the web service definition so that it added the
interface to the dynamically generated class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top