: Microsoft.Data.Services.Client.Portable 을 윈도우 8은 VS2013액세스하는 동안 오류가 WCF 서비스는 내가 사용하여 표준 중 하나로, OData 클라이언트 건물입니다
이 난에 서비스 참조를 추가 한 프로젝트 (TMALiveData) 권한 부여. 이제 데이터를 검색하고 싶습니다. 다음 코드를 사용하고 있지만, 할 때, 최종 루프에서 널 포인터 참조를 얻습니다.
코드는 다음과 같습니다 내가 잘못이 분명 아무것도
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Services.Client;
namespace testLSconWithMSv2
{
public class testLSCon
{
static string mResult;
public static string result { get { return mResult; } }
public static void testREADLiveConnection()
{
Uri tmaLiveDataRoot = new Uri("https://xxx.azurewebsites.net/xxx.svc/");
TMLiveData.TMALiveData mLiveData = new TMLiveData.TMALiveData(tmaLiveDataRoot);
mResult = null;
DataServiceQuery<TMLiveData.JobType> query = (DataServiceQuery<TMLiveData.JobType>)mLiveData.JobTypes.Where(c => c.IsActive == true);
mResult = "Trying to READ the data";
try
{
query.BeginExecute(OnQueryComplete, query);
}
catch (Exception ex)
{
mResult = "Error on beginExecute: " + ex.Message;
}
}
private static void OnQueryComplete(IAsyncResult result)
{
DataServiceQuery<TMLiveData.JobType> query = result as DataServiceQuery<TMLiveData.JobType>;
mResult = "Done!";
try
{
foreach (TMLiveData.JobType jobType in query.EndExecute(result))
{
mResult += jobType.JobType1 + ",";
}
}catch (Exception ex)
{
mResult = "Error looping for items: " + ex.Message;
}
}
}
}
있습니까? 내가에서 MS의 예에 대한 접근 방식을 기반으로 한 : 당신이 DataServiceQuery<TMLiveData.JobType>
에 IAsyncResult
캐스팅하려고 노력하고 있기 때문에 How to Execute Async...
null 인 객체는 무엇입니까? –