2013-06-04 10 views
5

これは私が使用しているメソッドです。MobileServiceInvalidOperationException Azureからデータを取得しようとするとき

try 
{ 
    List<Patient> pList = await App.MobileService.GetTable<Patient>().Where(
       patient => patient.id == 1).ToListAsync(); 
    foreach (Patient p in pList) 
    { 
     System.Diagnostics.Debug.WriteLine("{0}, {1}", p.id, p.first_name); 
    } 
} 
catch (Exception err) 
{ 
    System.Diagnostics.Debug.WriteLine("ERROR! : {0}", err.Message); 
} 

ここには患者エンティティがあります。

class Patient 
{ 
    public int id { get; set; } 
    public string first_name { get; set; } 
    public string last_name { get; set; } 
    public string middle_name { get; set; } 
    public string nirc { get; set; } 
    public int bed_id { get; set; } 
} 

ここではエラーが発生しています。私はTryCatch以内に私の方法をラップする場合

An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll and  wasn't handled before a managed/native boundary 
An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary 
An exception of type 'System.Net.WebException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 
An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.DLL and wasn't handled before a managed/native boundary 
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in Microsoft.Azure.Zumo.WindowsPhone8.Managed.DLL and wasn't handled before a managed/native boundary 
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 
A first chance exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll 
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 

、私はこのメッセージ

Error : The request could not be completed. () 

はここでスタックエラーメッセージ

at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.CreateMobileServiceException(String errorMessage, IServiceFilterRequest request, IServiceFilterResponse response) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.ThrowInvalidResponse(IServiceFilterRequest request, IServiceFilterResponse response, JToken body) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.<RequestAsync>d__f.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<SendReadAsync>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<EvaluateQueryAsync>d__3`1.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTableQuery`1.<ToListAsync>d__2.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at PhoneApp1.MainPage.<populate>d__0.MoveNext() 

注意すべきいくつかのポイントがあります取得します。

  1. 許可はAnybody with the Application Key
  2. に設定されている私は既にApp.XAML.CS.内にこのコードを挿入したWindows Azure Mobile Services Managed Client
  3. への参照を追加しましたusing Microsoft.WindowsAzure.MobileServices;
  4. 私は既にthisウェブサイトから取得したこのコードをApp.XAML.CS内に配置しました。
    public static MobileServiceClient MobileService = new MobileServiceClient(AppUrl, AppKey);

なぜ私は私のデータベースに接続することができませんか。私はこれらのコードをWindows Storeアプリケーションで実行しようとしました。以前はまったく同じことをやっていましたが、うまくいきました。

答えて

3

This link me saved。

明らかに、サービスアドレスをhttpsからhttpに変更するだけです。これに代えて、

public static MobileServiceClient MobileService = new MobileServiceClient( 
    "https://www.example.azure-mobile.net/", 
    "fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa" 
); 

変更それ

public static MobileServiceClient MobileService = new MobileServiceClient( 
    "http://www.example.azure-mobile.net/", 
    "fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa" 
); 

にそう問題は解決しました。

+2

これは問題を「解決」しないため、回避します。これにより、HTTPSが無効になり、データがクリアテキストで送信されるようになりました。これはおそらく良いことではありません。私の場合、HTTPSが失敗したデバイスで日付/時刻が間違っていました。 –

0

評価が低いためコメントできません。同じ問題が発生していますが、矛盾しています。

アズールモバイルサービスに当たるアプリケーションで登録ページを使用しようとすると、同じエラー(「リクエストを完了できませんでした。」)がタイムアウトすることがあります。それはうまく動作します。

私は実際のWindows Phone Deviceを使用しています。実際には4Gなので、iPhoneのホットスポットで提供されているWi-Fiを使って接続しています。接続に問題はありません。

私は、インターネット接続が利用可能かどうかをチェックし、データを送信して何らかの問題に取り組むことを試みることは何の意味もないと言った他の記事を読んだ。私はこの問題に対処するが、問題は起こってはならない。

これ以上問題が発生しましたか?

MobileService接続にhttpsとhttpを使用しようとしましたが、違いはありません。

+0

誰にもアイデアはありますか? – xceed

2

コンピュータまたはデバイスの日付/時刻を確認してください。私の場合は、しばらくの間オフになっていたデベロッパーの携帯電話を使用していましたが、日付/時刻は完全に間違っていました。エンドポイントをHTTPSからHTTPに変更することで問題は解決しますが、私にとっては適切な解決策はHTTPSを保持し、デバイスの日付/時刻を修正することでした。

+0

これは正解です。不正なテストデバイスのためにhttpsを無効にしないでください。 –

0

他の誰かがこの問題に遭遇した場合、誤ったサブドメインのURLをMobileServiceClientに渡しただけで同じ問題が発生しました。例えば

、このような何か:

public static MobileServiceClient MobileService = new MobileServiceClient( 
 
    "http://www.example.azure-mobile.net/", 
 
    "fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa" 
 
);

-1

もこれがオフになっていることを確認してください。

enter image description here

1

私は私のAndroidデバイスでこの問題を解決しました。あなたは、あなたのアプリのインスタンスを殺す必要がありますシステムの日付/時間を現在に変更し、アプリを再度開きます。

ありがとうNathanial Woolls !!!

関連する問題