wp8.1 실버 라이트로 wcf를 사용하는 데 문제가 있습니다. 내가 countinously 오류 받고 계약 'IPhoneService'실버 라이트에서 지원되지 않는 동기 작업이 포함되어 있습니다. 작업을 "Begin"및 "End"파트로 분할하고 OperationContractAttribute의 AsyncPattern 속성을 'true'로 설정합니다. 서버에서 동일한 변경을 수행 할 필요는 없습니다. syncronous 메서드를 async로 변경 한 후에도 여전히 동일한 오류가 발생합니다 (서비스 참조를 업데이트했습니다.). 호기심에서 콘솔 앱에서 사용하려고했는데 완벽하게 작동합니다. 이전에 내가 그와 관련이있을 수있는 또 다른 오류가 발생했습니다. 서비스 참조를 추가하면 app.config 파일이 생성되었지만 ServiceReferences.ClientConfig가 필요하므로 간단히 이름을 변경했습니다. Windows Phone 용 WCF 8.1 실버 라이트
public int GetData()
{
return 12;
}
내 MainViewModel에
(나는 MVVMLight 툴킷을 사용하고 있습니다) :는 지금 내가 syncronous하는 WCF 방법을 다시 변경
public void Load()
{
var client = new ServiceReference1.PhoneServiceClient();
client.GetDataCompleted += client_GetDataCompleted;
client.GetDataAsync();
}
void client_GetDataCompleted(object sender, ServiceReference1.GetDataCompletedEventArgs e)
{
Title = e.Result.ToString();
}
와 나는 같은 비동기 방식 전에 implemeneted 그래도 같은 오류가 발생합니다.
public IAsyncResult BeginGetData(AsyncCallback callback, object asyncState)
{
var msg = 12;
return new CompletedAsyncResult<int>(msg);
}
public int EndGetData(IAsyncResult r)
{
CompletedAsyncResult<int> result = r as CompletedAsyncResult<int>;
return result.Data;
}
class CompletedAsyncResult<T> : IAsyncResult
{
T data;
public CompletedAsyncResult(T data)
{ this.data = data; }
public T Data
{ get { return data; } }
#region IAsyncResult Members
public object AsyncState
{ get { return (object)data; } }
public WaitHandle AsyncWaitHandle
{ get { throw new Exception("The method or operation is not implemented."); } }
public bool CompletedSynchronously
{ get { return true; } }
public bool IsCompleted
{ get { return true; } }
#endregion
}