![](/img/trans.png)
[英]Release mode UWP app crashes when in tablet mode and with code in OnSuspended
[英]UWP - WebAuthenticationBroker crashes on device in release mode
我正在制作使用OAuth2的UWP應用。 我使用的是WebAuthenticationBroker類,在設備上進行調試時很好,但是更改為發行並運行會導致應用程序在應打開身份驗證對話框時崩潰。 這是代碼,幾乎是他們在MSDN上給您的樣板。
try {
var webAuthenticationResult = await Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(Windows.Security.Authentication.Web.WebAuthenticationOptions.None, startURI);
switch (webAuthenticationResult.ResponseStatus) {
case Windows.Security.Authentication.Web.WebAuthenticationStatus.Success:
// Successful authentication.
var uri = new Uri(webAuthenticationResult.ResponseData);
var index = uri.Query.IndexOf('=') + 1;
code = uri.Query.Substring(index);
_accessToken = await GetAccessToken(code);
vault.Add(new PasswordCredential("myApp", "token", Token));
break;
case Windows.Security.Authentication.Web.WebAuthenticationStatus.ErrorHttp:
// HTTP error.
throw new HttpRequestException(webAuthenticationResult.ResponseErrorDetail.ToString());
default:
// Other error.
throw new Exception(webAuthenticationResult.ResponseData.ToString());
}
} catch (Exception ex) {
// Authentication failed. Handle parameter, SSL/TLS, and Network Unavailable errors here.
throw ex;
}
事實證明,我需要為此特定API傳遞第三個參數作為結束URI。 不確定為什么在調試中還可以,但是...現在看來一切都很好。 只需擺脫手機頂部的邊距即可。 我確實做了一件事,在項目的屬性中,我選擇了刪除所有數據的選項。 我不確定這是否有任何作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.