BrunoWB BrunoWB - 1 month ago 15
C# Question

Xamarin, return WCF data to PCL from specific platform libraries

I'm working on a client/server project but struggling to make it work, mostly because

System.ServiceModel
cannot be accessed in PCL.

But that's OK, I managed to use
DependencyServices
that I call from PCL to manage the connection with the server from each specific platform.

My problem is, once I call for example

var result = DependencyService.Get<Interface>().Operation(param);


this will go to the platform specific, there I'm doing the binding, endpoint and calling the real operation from WCF, that is Async, so from now I cannot return the result from WFC in this method, because this will be returned to another method once the operation is completed.

My goal is to do most of the job on PCL so I don't have to start writing my interface multiple times for each platform. So in resume what I need is a way to return result from server (WCF, or some other that would make it work) in my PCL.

Answer

enter image description hereCreate WCF proxy/client in PCL using VS and avoid all these problems

enter image description here

Comments