簡體   English   中英

Visual Studio 2017 工作室顯示錯誤“此應用程序處於中斷模式”並引發未處理的異常

[英]Visual Studio 2017 studio showing error 'This application is in break mode' and throws unhandled exception

我正在開發 Xamarin.Android 應用程序。 每當我嘗試下載 JSON 提要時,我都會收到錯誤消息“您的應用程序已進入中斷狀態,但沒有代碼可顯示,因為所有線程都在執行外部代碼”

這是錯誤的截圖這是錯誤的截圖

  • 我的json提要下載代碼

     string url = "http://xamdev.epizy.com/getData1.php"; public async void downloadJsonFeedAsync(String url) { var httpClient = new HttpClient(); Task<string> contentsTask = httpClient.GetStringAsync(url); // await! control returns to the caller and the task continues to run on another thread string content = await contentsTask; Console.Out.WriteLine("Response Body: \\r\\n {0}", content); //Convert string to JSON object result = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject> (content); //Update listview RunOnUiThread (() => { listView.Adapter = new CusotmListAdapter(this, result.posts); progress.Visibility = ViewStates.Gone; }); }
  • 我在這一行有錯誤

    字符串內容 = 等待內容任務;

  • 這是我的json

    { "posts":[ { "id":"1", "url":"", "title":"在 Android 應用程序中將語音轉換為文本", "date":"2017-06-16 06:15: 18", "content":"Convert Speech to Tex Convert Speech to Text in Android Application Convert Speech to Text in Android Applicationt in Android Application", "thumbnail":"http:\\/\\/st​​acktips.com\\/wp-content \\/uploads\\/2017\\/01\\/Speech-to-Text-in-Android-375x300.jpeg" } ] }

請有人告訴我我的代碼有什么問題嗎? 提前致謝..

這是我的 php 網絡服務代碼-

<?php 

if($_SERVER['REQUEST_METHOD']=='GET'){

    require_once('conn.php');

    $sql = "SELECT * FROM space";


    if ($result = mysqli_query($conn, $sql))
     {
      $resultArray = array();
      $tempArray = array();


       while($row = $result->fetch_object())
       {

         $tempArray = $row;
          array_push($resultArray, $tempArray);
      }


    echo json_encode(array("result"=>$resultArray));
    }
        mysqli_close($conn);

     }
   ?>               

我很驚訝但不是針對此問題發布的最佳答案。 對我來說,上述解決方案不起作用。 要解決此問題,我將禁用調試菜單中的以下選項。

Debug > Options > General > Uncheck "Enable Just My Code"

有關更多詳細信息,請查看microsoft msdn幫助。

您應該獲得異常詳細信息和調用堆棧,這將大大有助於您的調試工作。 我認為這是目前 VS2017 上 Xamarin 的一個錯誤。

我遇到了這個錯誤,並在應用程序失敗后查看了輸出窗口。 在我的例子中,我在視圖模型類中有一個方法,其中有一個由 XMAL 調用的“任務”。

最后我得到了答案。

問題出在我的托管服務器上,服務器響應中包含 cookie。 這就是為什么我的 android 應用程序無法解析 json 的原因。

謝謝你的幫助。

在我的特殊情況下,我檢查了調試輸出窗口,它提到“無法找到或打開 PDB 文件”。 我進一步閱讀,其中一個解決方案是檢查我所做的靜態變量引用。 我從 AppSettings 加載了一個靜態變量,它引用了 app.Config 文件中不存在的鍵。 我希望調試器直接告訴我找不到引用或類似的東西。 一旦我有了正確的參考密鑰,我就上路了。 希望這會幫助別人。

如果它幫助某人:

輸出選項卡給我一條消息,說 dll 版本不正確。

項目無論如何都運行了,但由於某種原因,這個 dll 版本使我的項目進入中斷模式,我刪除了 dll,使用了以前的版本,現在我可以毫無問題地調試了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM