Common WCF client code between .NET and Silverlight applications?

I am developing a .NET application that will have both WinForms and Silverlight client. Although most of the code will be on the server, I also need to have quite a bit of logic in the clients, and I would like to leave the client library code the same.

From what I could guess so far, I need to have two different types of projects: a class library and a Silverlight class library, and link files from one project to another. This seems a bit lame, but it works for simple code.

My problem is that the code generated by SVCUtil.exe to access WCF services is different from the code generated by slsvcutil.exe , and the silverlight code is actually not compatible with .NET: I get a bunch of problems with the System.ServiceModel.Channel classes when I try to import a class in .NET.

Has anyone done anything like this before? What am I doing wrong?

+3
source share
3 answers

Unfortunately, with Silverlight 3 and .NET 3.5sp1 there is no binary compatibility. You must share files and maintain two separate libraries.

Silverlight 4 .NET 4, , . , , Silverlight Windows Forms.

+2
+2

- - - .

You can reuse data classes between projects using the link method you described. If a new version of classes is created in the proxy, you can simply edit the created proxy code files and delete the class definitions. When you compile this, each client (Windows application and silverlight) will have its own version of the compiled class library, but it all comes from the same source code.

0
source

Source: https://habr.com/ru/post/1737726/


All Articles