Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Sharing assembly between client and service

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 03-22-2007   #1 (permalink)
jmagaram
Guest


 

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
Guest


 

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
Guest


 

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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Print sharing: XP client to Vista service in domain Dave Harry Vista networking & sharing 2 10-10-2007 12:06 AM
Client Service for Netware Badger Vista installation & setup 0 09-14-2006 01:33 PM


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com 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 2005-2008