Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Uwp应用程序可以';t使用net.tcp连接到Wcf服务_C#_Wcf_Uwp_Net.tcp - Fatal编程技术网

C# Uwp应用程序可以';t使用net.tcp连接到Wcf服务

C# Uwp应用程序可以';t使用net.tcp连接到Wcf服务,c#,wcf,uwp,net.tcp,C#,Wcf,Uwp,Net.tcp,我有一个Wcf服务,该服务已被WinForm应用程序和内部网内的asp.net站点成功使用。现在我正在将WinForm应用程序重写为Uwp应用程序。我已经安装了最新的Framework 4.7.2和Net.Core 2.1。我如何使用Uwp提供的服务?我尝试使用以下方式连接到我的服务: var binding = new NetTcpBinding(SecurityMode.Transport); binding.Security.Transport.Client

我有一个Wcf服务,该服务已被WinForm应用程序和内部网内的asp.net站点成功使用。现在我正在将WinForm应用程序重写为Uwp应用程序。我已经安装了最新的Framework 4.7.2和Net.Core 2.1。我如何使用Uwp提供的服务?我尝试使用以下方式连接到我的服务:

        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";
在我呼叫我的服务后:

var towers = await wcf_client.GetTowersAsync();
我得到一个错误:

在System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult结果) 位于System.ServiceModel.Channel.ServiceChannel.SendAsyncResult.End(SendAsyncResult) 位于System.ServiceModel.Channels.ServiceChannel.EndCall(字符串操作,对象[]输出,IAsyncResult结果) 在System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.c\uu DisplayClass1\u 0.b\uu 0(IAsyncResult asyncResult) ---来自引发异常的上一个位置的堆栈结束跟踪--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中 在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中 在UwpApp.MainPage.d_uu1.MoveNext()中 ---来自引发异常的上一个位置的堆栈结束跟踪--- 在System.Runtime.CompilerServices.AsyncMethodBuilderCore.c.b_uu6_0(对象状态)中 位于System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()处


你能提供例外情况的详细信息吗?不仅是堆栈跟踪。还有你的uwp应用程序目标版本。@Sunteen Wu我尝试了另一个代码。已获取套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:00:59.7099734”。您是否启用了
企业身份验证
专用网络(客户端和服务器)
功能?另外,请避免将问题作为答案。请将其编辑为您的原始线程。