简体   繁体   English

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

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

I am developing a Xamarin.Android app.我正在开发 Xamarin.Android 应用程序。 Whenever i try to download a JSON feed I get the error "Your app has entered a break state, but there is no code to show because all threads were executing external code" .每当我尝试下载 JSON 提要时,我都会收到错误消息“您的应用程序已进入中断状态,但没有代码可显示,因为所有线程都在执行外部代码”

Here's the screenshot of error这是错误的截图这是错误的截图

  • My json feed download code我的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; }); }
  • i have got error at this line我在这一行有错误

    string content = await contentsTask;字符串内容 = 等待内容任务;

  • This is my json这是我的json

    { "posts":[ { "id":"1", "url":"", "title":"Convert Speech to Text in Android Application", "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:\\/\\/stacktips.com\\/wp-content\\/uploads\\/2017\\/01\\/Speech-to-Text-in-Android-375x300.jpeg" } ] } { "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" } ] }

Please can anybody tell me whats wrong with my code ?请有人告诉我我的代码有什么问题吗? Thanks in advance..提前致谢..

Here's my php webservice code -这是我的 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);

     }
   ?>               

I'm surprised yet not best answer posted for this issue.我很惊讶但不是针对此问题发布的最佳答案。 For me above solutions didn't work.对我来说,上述解决方案不起作用。 To resolve this issue, I'd to disable following option from debug menu.要解决此问题,我将禁用调试菜单中的以下选项。

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

For more details, check microsoft msdn help.有关更多详细信息,请查看microsoft msdn帮助。

You should be getting exception details and a call stack, which will greatly aid in your debugging efforts.您应该获得异常详细信息和调用堆栈,这将大大有助于您的调试工作。 I think this is a bug with Xamarin on VS2017 right now.我认为这是目前 VS2017 上 Xamarin 的一个错误。

I ran across this error and looked in the output window after the application failed.我遇到了这个错误,并在应用程序失败后查看了输出窗口。 In my case I had a method in a view model class with a "Task" that is invoked by the XMAL.在我的例子中,我在视图模型类中有一个方法,其中有一个由 XMAL 调用的“任务”。

At last i got the answer.最后我得到了答案。

Problem was with my hosting server, server response with cookies in it.问题出在我的托管服务器上,服务器响应中包含 cookie。 That's why my android app unable to parse the json.这就是为什么我的 android 应用程序无法解析 json 的原因。

Thanks for help.谢谢你的帮助。

In my particular case I checked the debug output window and it mentioned "Cannot find or open the PDB file."在我的特殊情况下,我检查了调试输出窗口,它提到“无法找到或打开 PDB 文件”。 I further read and one of the solutions was to check what static variable references I was making.我进一步阅读,其中一个解决方案是检查我所做的静态变量引用。 I had a static variable loading from the AppSettings and it was referencing a key that was not present in the app.Config file.我从 AppSettings 加载了一个静态变量,它引用了 app.Config 文件中不存在的键。 I wish the debugger told me directly the reference not found or something like that.我希望调试器直接告诉我找不到引用或类似的东西。 Once I had the correct reference key, I was on my way.一旦我有了正确的参考密钥,我就上路了。 Hoping this will help somebody else.希望这会帮助别人。

In case it helps someone:如果它帮助某人:

The output tab was giving me a message saying that the dll version was incorrect.输出选项卡给我一条消息,说 dll 版本不正确。

The project ran anyway, but for some reason this dll version made my project to go to break mode, I deleted the dll, used a previous version, and now I can debug without problems项目无论如何都运行了,但由于某种原因,这个 dll 版本使我的项目进入中断模式,我删除了 dll,使用了以前的版本,现在我可以毫无问题地调试了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM