Visual Studio 2017 Studio显示错误``此应用程序处于中断模式''并引发未处理的异常 [英] Visual Studio 2017 studio showing error 'This application is in break mode' and throws unhandled exception
问题描述
我正在开发Xamarin.Android应用.每当我尝试下载JSON feed时,都会出现错误您的应用已进入中断状态,但由于所有线程都在执行外部代码,所以没有可显示的代码" .
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
-
我的json提要下载代码
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
字符串内容=等待contentsTask;
string content = await contentsTask;
这是我的json
{ 帖子":[ { "id":"1", "url":", "title":在Android应用程序中将语音转换为文本", "date":"2017-06-16 06:15:18", "content":将语音转换为Tex,在Android应用程序中将语音转换为文本,在Android应用程序中,在Android Applicationt中转换语音为文本", 缩略图":"http:\/\/stacktips.com \/wp-content \/uploads \/2017 \/01 \/Speech-to-Text-in-Android-375x300.jpeg" } ] }
{ "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..
这是我的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);
}
?>
推荐答案
最后我得到了答案.
问题出在我的托管服务器上,服务器响应中包含cookie.这就是为什么我的Android应用无法解析json的原因.
Problem was with my hosting server, server response with cookies in it. That's why my android app unable to parse the json.
感谢您的帮助.
这篇关于Visual Studio 2017 Studio显示错误``此应用程序处于中断模式''并引发未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!