How to use duplex wcf service in Windows Universal App

How can I use a duplex contract wcf service in a universal Windows application?

I get an exception when I execute PlatformNotSupportedExcetpion: Operation is not supported on this platform. when trying to use the wcf duplex service in the Windows Universal App, focusing on Windows 10 (10.0; Build 10240)

According to msdn , the API is supported.

If this is not possible, how should I continue in my scenario? I have two applications (console and window universal xaml application) running on the same computer, and I need two-way communication.

I have a clasic.net 4.6 console application that creates a service host:

 var host = new ServiceHost(typeof(MyService), new Uri("net.tcp://localhost:8008/MyService")); var binding = new NetTcpBinding(); //I've also tried net http binding binding.Security.Mode = SecurityMode.None; host.Description.Behaviors.Add(new ServiceMetadataBehavior()); host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex"); host.AddServiceEndpoint(typeof(IMyService), binding, ""); host.Open(); 

service contract:

 [ServiceContract(CallbackContract = typeof(IMyServiceCallback))] public interface IMyService { [OperationContract(IsOneWay = true)] void Initialize(); } public interface IMyServiceCallback { [OperationContract(IsOneWay = true)] void OnFrame(int i); } 

I tried both ChannelFactory and the generated wcf client using the Add Service Link dialog box and NetHttpBinding and NetTcpBinding in a UWP application.

When I try to create an instance of the wcf client, it returns the value PlatformNotSupportedExcetpion.

Source: System.Private.ServiceModel

Stacktrace:

  at System.ServiceModel.ReflectionExtensions.GetInterfaceMap(Type type, Type interfaceType) at System.ServiceModel.Description.TypeLoader.GetIOperationBehaviorAttributesFromType(OperationDescription opDesc, Type targetIface, Type implType) at System.ServiceModel.Description.TypeLoader.<>c__DisplayClass8.<AddBehaviorsFromImplementationType>b__10(Type currentType, KeyedByTypeCollection`1 behaviors) at System.ServiceModel.Description.TypeLoader.AddBehaviorsAtOneScope[IBehavior,TBehaviorCollection](Type type, TBehaviorCollection descriptionBehaviors, ServiceInheritanceCallback`2 callback) at System.ServiceModel.Description.TypeLoader.AddBehaviorsFromImplementationType(ServiceEndpoint serviceEndpoint, Type implementationType) at System.ServiceModel.ChannelFactory`1.ReflectOnCallbackInstance(ServiceEndpoint endpoint) at System.ServiceModel.ChannelFactory`1.CreateDescription() at System.ServiceModel.ChannelFactory.InitializeEndpoint(Binding binding, EndpointAddress address) at System.ServiceModel.DuplexChannelFactory`1..ctor(Object callbackObject, Binding binding, EndpointAddress remoteAddress) at System.ServiceModel.ClientBase`1..ctor(InstanceContext callbackInstance, Binding binding, EndpointAddress remoteAddress) at System.ServiceModel.DuplexClientBase`1..ctor(InstanceContext callbackInstance, Binding binding, EndpointAddress remoteAddress) at App1.ServiceReference1.MyServiceClientBase..ctor(InstanceContext callbackInstance) at App1.ServiceReference1.MyServiceClient..ctor(MyServiceClientCallback callbackImpl) at App1.ServiceReference1.MyServiceClient..ctor() at App1.MainPage.<button_Click>d__1.MoveNext() 
+6
source share
2 answers

Duplex scripting is not supported even in build 10580 (latest version of .NETCore v5.1.0).

A GitHub error was reported about the erroneous use of reflection in a duplex WCF implementation. This bug was fixed in the latest build for the .net kernel, and you can enable an individual package from the Nuget gallery. However, this package also requires the inclusion of pre-release versions of System.Runtime and System.Threading.

enter image description here

Hope this helps,

0
source

Stable versions of WCF as part of .NET Core 1.0 were only released last month. Duplex and many other WCF features can now be supported in Windows Universal Apps, referring to version 5.2.2 of the Microsoft.NETCore.UniversalWindowsPlatform in the project.json file of the UWP project.

+4
source

All Articles