我在我的Windows应用程序和web服务中使用webservice我有一个方法返回一个Locations
数组,这是一个自定义类型。我尝试了以下代码:
ASMXWebServiceReference.WebServiceSoapClient MyASMXWebServiceClient = new ASMXWebServiceReference.WebServiceSoapClient();
ASMXWebServiceReference.RetrieveFollowingLocationsResponse MyFollowingLocations = await MyASMXWebServiceClient.RetrieveFollowingLocationsAsync("[email protected]");
ASMXWebServiceReference.Location[] locations = new ASMXWebServiceReference.Location[];
locations = MyFollowingLocations.Body.RetrieveFollowingLocationsResult;
位置类看起来像:http://tinypic.com/r/1z23wv6/8
我收到此错误:
错误无法将类型'System.Collections.ObjectModel.ObservableCollection'隐式转换为'App9.ASMXWebServiceReference.Location []'
您正在尝试将一个ObservableCollection类型分配给一个不起作用并导致异常的数组。在将ObservableCollection分配给数组属性之前,需要将其转换为数组:
locations = MyFollowingLocations.Body.RetrieveFollowingLocationsResult.ToArray();