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# WCF e.结果为空_C#_Wcf_Serialization_Windows Phone 8 - Fatal编程技术网

C# WCF e.结果为空

C# WCF e.结果为空,c#,wcf,serialization,windows-phone-8,C#,Wcf,Serialization,Windows Phone 8,我正在调用WCF服务,但结果返回为null。然而,当我在浏览器中运行服务时,我可以看到JSON被返回,没有问题 代码: 在webClient_OpenreadCompleted事件中: ser = new DataContractJsonSerializer(typeof(ObservableCollection<SightingType>)); List<SightingType> sightingTypes = ser.ReadObject(e.Result) as

我正在调用WCF服务,但结果返回为null。然而,当我在浏览器中运行服务时,我可以看到JSON被返回,没有问题

代码:

在webClient_OpenreadCompleted事件中:

ser = new DataContractJsonSerializer(typeof(ObservableCollection<SightingType>));
List<SightingType> sightingTypes = ser.ReadObject(e.Result) as List<SightingType>;
ser=newdatacontractjsonserializer(typeof(ObservableCollection));
List sightingTypes=ser.ReadObject(e.Result)作为列表;
但由于某种原因,目击类型被证明是空的。此外,当我在调试时将鼠标悬停在e.Result上时,我可以看到以下错误:

ReadTimeout='e.Result.ReadTimeout'引发了类型为的异常 “System.InvalidOperationException”


有人知道我为什么不能取回数据吗?

你有没有用同步调用测试过URI?并且总是先检查
e.Error
,然后再进行调查。只是猜测一下,但转换到
列表是否有问题?我会尝试将其更改为:
var-sightingTypes=ser.ReadObject(e.Result)看看你得到了什么,然后尝试一些不同的强制转换方法。如果我使用var,我只看到“object”这个词,我不能进入它。@Henk你能举一个同步调用的例子吗?
ser = new DataContractJsonSerializer(typeof(ObservableCollection<SightingType>));
List<SightingType> sightingTypes = ser.ReadObject(e.Result) as List<SightingType>;