![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| 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 | |||