C# Windows应用商店应用程序C捕获错误
我正在开发一个Windows应用商店应用程序,但是我使用此方法在应用程序第一次打开时生成用户idC# Windows应用商店应用程序C捕获错误,c#,windows-store-apps,try-catch,windows-store,C#,Windows Store Apps,Try Catch,Windows Store,我正在开发一个Windows应用商店应用程序,但是我使用此方法在应用程序第一次打开时生成用户id private string host = "http://etc.com"; public async void RegisterUsuario() { string displayName = await UserInformation.GetDisplayNameAsync(); string url = host + "/json/Register.php?code=" +
private string host = "http://etc.com";
public async void RegisterUsuario() {
string displayName = await UserInformation.GetDisplayNameAsync();
string url = host + "/json/Register.php?code=" + displayName;
try
{
var http = new HttpClient();
var jsonText = await http.GetStringAsync(url);
var jsonValues = JsonArray.Parse(jsonText)[0];
var status = jsonValues.GetObject().GetNamedString("status");
if (status == "error")
{
var dialog = new MessageDialog("No se pudo registrar tu usuario", "¡Oops!");
await dialog.ShowAsync();
}
else
{
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
localSettings.Values["usuario"] = jsonValues.GetObject().GetNamedNumber("id");
}
}
catch {
alertCatch("No se pudo registrar tu usuario");
}
}
JSON响应:
[{状态:成功,id:32}]
问题是:
在我的电脑中,它总是工作正常,但当我将应用程序提交到windows应用商店时,我总是会收到以下信息:
与捕获中显示应用程序的错误相同
你能帮我个忙吗,也许是appxmanifest里的事
在功能中,我选择了专用和公用网络您消除此错误的第一步是给自己一个错误。您实际上可以将精力投入捕获异常中,例如{alertCatchex.message;}找出实际发生的情况,并将错误消息发回给我们