Visual Studio 2017 studio 显示错误“此应用程序处于中断模式”并引发未处理的异常

2024-03-17

我正在开发 Xamarin.Android 应用程序。每当我尝试下载 JSON feed 时都会收到错误“您的应用程序已进入中断状态,但没有代码可显示,因为所有线程都在执行外部代码”.

Here's the screenshot of error Here's the screenshot of error

  • 我的 json feed 下载代码

     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

    { “帖子”:[ { “id”:“1”, “网址”:“”, "title":"在 Android 应用程序中将语音转换为文本", "日期":"2017-06-16 06:15:18", "content":"将语音转换为 Tex 在 Android 应用程序中将语音转换为文本 在 Android 应用程序中将语音转换为文本", “缩略图”:“http:\/\/st​​acktips.com \/wp-content \/uploads \/2017 \/01 \/Speech-to-Text-in-Android-375x300.jpeg” } ] }

请有人告诉我我的代码有什么问题吗? 提前致谢..

这是我的 php webservice 代码-

<?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"

欲了解更多详情,请查看微软MSDN https://msdn.microsoft.com/en-us/library/dn457346.aspx help.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Visual Studio 2017 studio 显示错误“此应用程序处于中断模式”并引发未处理的异常 的相关文章

随机推荐