我构建了一个简单的IoT UWP应用程序,其中包含1个按钮和1个文本字段。按下按钮将从WCF服务调用函数并在文本字段中显示结果。
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.ServiceModel.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.ServiceModel.CommunicationException' in System.Private.ServiceModel.dll
Exception thrown: 'System.ServiceModel.CommunicationException' in System.Private.CoreLib.dll
Exception thrown: 'System.ServiceModel.CommunicationException' in System.Private.CoreLib.dll
Exception thrown: 'System.ServiceModel.CommunicationException' in System.Private.ServiceModel.dll
Exception thrown: 'System.ServiceModel.CommunicationException' in System.Private.CoreLib.dll
An exception of type 'System.ServiceModel.CommunicationException' occurred in System.Private.CoreLib.dll but was not handled in user code
Additional information: net_http_client_execution_error
我的UWP中按钮的事件处理程序如下所示:
private async void button_GetData_Click(object sender, RoutedEventArgs e)
{
Service1Client cl = new Service1Client();
await cl.OpenAsync();
var res = await cl.GetDataAsync(12);
txtData.Text += res;
}
我的服务如下:
using System;
namespace WCF_Temp
{
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
我没有想法......有人遇到同样的麻烦吗?
提前致谢! }
您的代码在您的WCF中很简单,您的客户端代码也很简单。因此,如果只检查您的代码段,很难找到您的问题。
您可能需要进行故障排除。例如,
此外,如果您不知道如何调试WCF服务,请查看此文档Debugging WCF Services