visual-studio - 调试器已附加到 UWP.exe,但未配置为处理此未处理异常。 | Combase.Pdb 未加载?

标签 visual-studio xamarin uwp xamarin.forms windows-10-universal

我正在开发一个 xamarin Forms 应用程序并将其部署到 UWP 本地计算机以进行测试。它有一个简单的电子邮件检查器表单,可以调用 ASP.NET Web API 来验证数据库中是否存在电子邮件。当我单击“下一步”按钮时,调试器停止并 this抛出异常。

我通过调试 uwp 项目的属性并将调试器类型从托管更改为混合找到了解决方案。我应用了更改、重建项目、部署,这次引发了另一个异常,如 this 所示。截图:

我在互联网上搜索了很多有关此问题的信息,但过去 4 天我无法找到其解决方案。请查看我的此表单代码并帮助我解决此问题。 以下是 GetUserEmailForm.Xaml 的代码:

 <StackLayout Spacing="20" VerticalOptions="Center" Padding="20">
    <Label HorizontalOptions="Center" Text="What's Your Email Address" FontSize="20" FontAttributes="Bold" TextColor="Navy" />
    <Entry x:Name="txtEmail" Placeholder="Enter your Email" PlaceholderColor="Gray" HorizontalOptions="FillAndExpand" />
    <Button Text="Next" Clicked="Button_OnClicked" TextColor="White" BackgroundColor="Teal" WidthRequest="200" HorizontalOptions="Center" />
    <ActivityIndicator x:Name="indi" Color="Red" IsVisible="False" />
</StackLayout>

以下是 GetUserEmailForm.Xaml.cs 的代码:

 [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class GetUserEmailForm : ContentPage
{
    public Customer cust;
    public GetUserEmailForm()
    {
        InitializeComponent();
    }

    private async void Button_OnClicked(object sender, EventArgs e)
    {
        indi.IsVisible = true;
        var x = await PostData();
        indi.IsVisible = false;
    }

    public async Task<Customer> PostData()
    {
        cust.Email = txtEmail.Text;

        using (HttpClient client = new HttpClient())
        {
            var data = JsonConvert.SerializeObject(cust);
            var content = new StringContent(data, Encoding.UTF8, "application/json");
            var response = await client.PostAsync("http://localhost:1214/api/PasswordReset", content);
            if (response.StatusCode == HttpStatusCode.OK)
            {
                //  isCreated = true;
                await DisplayAlert("Success", "Email found, We will send you a code to validate this Email." +
                                              " Please check your email and verify it on next screen.", "OK");
                var result = JsonConvert.DeserializeObject<Customer>(response.Content.ReadAsStringAsync().Result);
                return result;

            }
            else
            //if (response.StatusCode == HttpStatusCode.Conflict)
            {
                await DisplayAlert("Failed", "Email does not exist in the system.Try Again.", "OK");
                var result = JsonConvert.DeserializeObject<Customer>(response.Content.ReadAsStringAsync().Result);
                return result;
            }
        }
    }
}

我尝试通过在 API 调用行上放置断点来检查此代码,但即使在到达断点之前也会引发异常。我将非常感谢您的宝贵意见。 谢谢

最佳答案

单击您的 UWP 项目,然后转到“项目”>“属性...”

如果 Visual Studio 配置为仅调试托管异常并且您获得的异常是 native 异常,则可能会出现此警告。转到项目属性的“调试”选项,然后将调试器类型从“仅托管”更改为“混合”(托管和 native )。

关于visual-studio - 调试器已附加到 UWP.exe,但未配置为处理此未处理异常。 | Combase.Pdb 未加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43424635/

相关文章:

c++ - 如何将 LLVM 5.0 集成到 Visual Studio 2017 中?

c# - Universal Windows App的水平StackPanel ScrollView

c# - 无法在 Flyout 的 TextBox 控件中输入输入文本

c# - 是否可以使用 Windows 应用程序打包项目打包两个 UWP 应用程序?

c# - 如何在ASP.NET Core Razor Pages项目中启用外部身份验证?

visual-studio - 如果多个文件具有相同的名称,Visual Studio 断点会在错误的源文件(或同时多个文件)中中断

Xamarin.Forms:UWP 应用的本地化

c# - 如何获取 Mono Xamarin Android 应用程序路径文件夹?

visual-studio - Visual Studio : What happened to the "Break when an exception is unhandled" option?

Xamarin Forms 在创建时异步填充数据