简体   繁体   中英

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

I am developing a Xamarin.Android app. 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" .

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

  • My json feed download code

     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

    { "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" } ] }

Please can anybody tell me whats wrong with my code ? Thanks in advance..

Here's my php webservice code -

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

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.

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.

At last i got the answer.

Problem was with my hosting server, server response with cookies in it. That's why my android app unable to parse the json.

Thanks for help.

In my particular case I checked the debug output window and it mentioned "Cannot find or open the PDB file." 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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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