Uwp app can't connect to Wcf service using net.tcp

210 views Asked by At

I have a Wcf service that is successfully used by WinForm app and asp.net site inside intranet. Now I am rewriting WinForm app to Uwp app. I have latest Framework 4.7.2 and Net.Core 2.1 installed. How can I consume my service from Uwp? I tryed connecting to my service using:

        var binding = new NetTcpBinding(SecurityMode.Transport);
        binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
        WcfService.WcfServiceClient wcf_client = new
                        WcfService.WcfServiceClient();
        wcf_client.Endpoint.Binding = binding;
        wcf_client.Endpoint.Address = new System.ServiceModel.EndpointAddress("net.tcp://server:8089/TeamCity");
        wcf_client.ClientCredentials.Windows.ClientCredential.UserName = "user";
        wcf_client.ClientCredentials.Windows.ClientCredential.Password = "password";

After I call my service:

var towers = await wcf_client.GetTowersAsync();

I get an error:

at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at UwpApp.MainPage.d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state) at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

0

There are 0 answers