Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Sharing assembly between client and service

 
 
Old 03-22-2007   #1 (permalink)
jmagaram


 
 

Sharing assembly between client and service

I am writing a simple application that requires communication between a
couple .NET applications and a .NET windows service, all running on the same
computer. I have complete control over all endpoints. I am using WCF but am
finding it difficult to share a class/assembly between client and service.
Should I be using Remoting instead?

My service contract has these functions:

MyConfiguration GetConfiguration();
void SaveConfiguration(MyConfiguration c);

The MyConfiguration class encapsulates data and a bunch of validation logic
and behavior. The client needs to work with this to present a proper UI and
validate the data. The service also needs to work with the same data and
validate it before persisting it. So I'd like to share this class between
client and service so I can avoid duplicate work. I understand why this
coupling of client and service can be a bad thing in some circumstances, but
here it seems fine. The proxy generation in Visual Studio creates a different
class for the client to work with - one that only has the data and no
validation logic. How can I get the service and the client to both work with
the same class? Do I always have to do a manual conversion between the proxy
class and the fully-functional one? Am I going about this wrong?

My System SpecsSystem Spec
Old 03-22-2007   #2 (permalink)
Mariano Omar Rodriguez


 
 

Re: Sharing assembly between client and service

You could use the ChannelFactory class.

using (ChannelFactory<MyServiceInterface> factory = new
ChannelFactory<MyServiceInterface>("MyClientConfig"))
{
MyServiceInterface service = factory.CreateChannel();
// Execute service mthods..
}

"jmagaram" <jmagaram@discussions.microsoft.com> wrote in message
news:FC20EED4-CCB3-4644-8DA0-9BAF506F515E@microsoft.com...
>I am writing a simple application that requires communication between a
> couple .NET applications and a .NET windows service, all running on the
> same
> computer. I have complete control over all endpoints. I am using WCF but
> am
> finding it difficult to share a class/assembly between client and service.
> Should I be using Remoting instead?
>
> My service contract has these functions:
>
> MyConfiguration GetConfiguration();
> void SaveConfiguration(MyConfiguration c);
>
> The MyConfiguration class encapsulates data and a bunch of validation
> logic
> and behavior. The client needs to work with this to present a proper UI
> and
> validate the data. The service also needs to work with the same data and
> validate it before persisting it. So I'd like to share this class between
> client and service so I can avoid duplicate work. I understand why this
> coupling of client and service can be a bad thing in some circumstances,
> but
> here it seems fine. The proxy generation in Visual Studio creates a
> different
> class for the client to work with - one that only has the data and no
> validation logic. How can I get the service and the client to both work
> with
> the same class? Do I always have to do a manual conversion between the
> proxy
> class and the fully-functional one? Am I going about this wrong?


My System SpecsSystem Spec
Old 04-10-2007   #3 (permalink)
Dwight@QuickLearn


 
 

Re: Sharing assembly between client and service

To keep your logic in place, you could use a custom DataContract Serializer,
and serialize your data into your shared class that contains the logic.

Use the <DataContractSerializer> element to specify it.

-HTH

"Mariano Omar Rodriguez" wrote:

> You could use the ChannelFactory class.
>
> using (ChannelFactory<MyServiceInterface> factory = new
> ChannelFactory<MyServiceInterface>("MyClientConfig"))
> {
> MyServiceInterface service = factory.CreateChannel();
> // Execute service mthods..
> }
>
> "jmagaram" <jmagaram@discussions.microsoft.com> wrote in message
> news:FC20EED4-CCB3-4644-8DA0-9BAF506F515E@microsoft.com...
> >I am writing a simple application that requires communication between a
> > couple .NET applications and a .NET windows service, all running on the
> > same
> > computer. I have complete control over all endpoints. I am using WCF but
> > am
> > finding it difficult to share a class/assembly between client and service.
> > Should I be using Remoting instead?
> >
> > My service contract has these functions:
> >
> > MyConfiguration GetConfiguration();
> > void SaveConfiguration(MyConfiguration c);
> >
> > The MyConfiguration class encapsulates data and a bunch of validation
> > logic
> > and behavior. The client needs to work with this to present a proper UI
> > and
> > validate the data. The service also needs to work with the same data and
> > validate it before persisting it. So I'd like to share this class between
> > client and service so I can avoid duplicate work. I understand why this
> > coupling of client and service can be a bad thing in some circumstances,
> > but
> > here it seems fine. The proxy generation in Visual Studio creates a
> > different
> > class for the client to work with - one that only has the data and no
> > validation logic. How can I get the service and the client to both work
> > with
> > the same class? Do I always have to do a manual conversion between the
> > proxy
> > class and the fully-functional one? Am I going about this wrong?

>
>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Print sharing: XP client to Vista service in domain Vista networking & sharing
How to install the Client service for Netware? Vista networking & sharing
Client Service for Netware Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46