Xamarin Forms 不调试和 ZXing 冻结所有应用程序

Xamarin Forms not Debugging and ZXing freezing all the application

我使用 Zxing on Xamarin 创建了一个读取二维码的应用程序。前天还好好的,昨天开始就出现了这个问题:

我在 OnAppearing() 方法中放置了一个断点,但它被忽略了,好吧...当我点击 Zxing 按钮打开扫描仪时,应用程序停止,但没有显示任何内容,只是冻结,没有错误,没有消息,没有调试,什么都没有。我的代码与工作时的代码相同,没有任何变化。如果有人能帮助我,我将不胜感激。

    public MainPage()
    {
        InitializeComponent();
        this.InitializeComponent();

        this.BindingContext = this;

        this.IsBusy = false;
    }

    protected override async void OnAppearing()
    {
        base.OnAppearing();
        var dados = new AcessoDB();

        if (dados.GetAlunos().Count() > 0)
        {
            var infopage = new Wallet();
            Navigation.InsertPageBefore(infopage, Navigation.NavigationStack[0]);
            await Navigation.PopToRootAsync();
            codeqr.IsEnabled = false;
        }
    }

    private async void Scan_Clicked(object sender, EventArgs e)
    {
        semaphoreSlim.Release();
        string img;
        this.IsBusy = true;


        if (CrossConnectivity.Current.IsConnected)
        {
            var scan = new ZXingScannerPage();
            await Navigation.PushAsync(scan);
            scan.OnScanResult += async (result) =>
            {
                bool liberado = await semaphoreSlim.WaitAsync(-1);
                if (!liberado)
                {
                    return;
                }
                scan.IsScanning = false;
                Device.BeginInvokeOnMainThread(async () =>
                {
                    if (CrossConnectivity.Current.IsConnected)
                    {
                        var parseResult = ResultParser.parseResult(result);

                        if (parseResult != null)
                        {
                            var hash = sha256_hash(result.ToString());
                            Aluno items = new Aluno();
                            try
                            {
                                scan.IsAnalyzing = false;
                                scan.IsScanning = false;
                                items = JsonConvert.DeserializeObject<Aluno>(result.ToString());
                                img = GetImage(items.Foto);
                            }
                            catch (Exception)
                            {
                                scan.IsScanning = false;
                                scan.IsAnalyzing = false;
                                await Navigation.PopAsync();
                                await DisplayAlert("Ops...", "Ocorreu algum erro com a leitura do seu código, tente de novo.", "Ok!");
                                return;
                            }
                            var info = new Aluno
                            {
                                Matricula = items.Matricula,
                                Nome = items.Nome,
                                RG = items.RG,
                                Nascimento = items.Nascimento,
                                Curso = items.Curso,
                                Campus = items.Campus,
                                Periodos = items.Periodos,
                                Modalidade = items.Modalidade,
                                Validade = items.Validade,
                                Hash = hash,
                                Foto = img
                            };

                            var infopage = new Wallet();
                            var dados = new AcessoDB();

                            if (!await dados.InserirAlunoAsync(info))
                            {
                                scan.IsAnalyzing = false;
                                scan.IsScanning = false;
                                await Navigation.PopAsync();
                                await DisplayAlert("Ops...", "Esse código não consta no nosso banco de dados, tem certeza que estuda no UGB?", "Repetir");
                                return;
                            }

                            try
                            {
                                scan.IsScanning = false;
                                scan.IsAnalyzing = false;
                                infopage.BindingContext = info;
                                Navigation.InsertPageBefore(infopage, Navigation.NavigationStack[0]);
                                await Navigation.PopToRootAsync();
                            }
                            catch (Exception)
                            {
                                scan.IsScanning = false;
                                scan.IsAnalyzing = false;
                                await DisplayAlert("Erro", "Não foi possível carregar a sua carteirinha.", "Ok...");
                            }
                        }
                    }
                });
            };
        }
        else
        {
            await DisplayAlert("Ops...", "Você não está conectado à internet.", "Ok!");
        }
        this.IsBusy = false;
    }

    public string GetImage(string foto)
    {
        if (String.IsNullOrEmpty(foto))
        {
            return "";
        }

        using (var WebClient = new WebClient())
        {
            var imageBytes = WebClient.DownloadData("http://portal.ugb.edu.br/upload/ImagemAluno/" + foto);
            var sxtyfr = Convert.ToBase64String(imageBytes);
            //var img = "data:image/jpg;base64," + sxtyfr;
            return sxtyfr;
        }
    }

    public static string sha256_hash(string value)
    {

        StringBuilder Sb = new StringBuilder(); using (SHA256 hash = SHA256Managed.Create())
        {

            Encoding enc = Encoding.UTF8;

            Byte[] result = hash.ComputeHash(enc.GetBytes(value)); foreach (Byte b in result)

                Sb.Append(b.ToString("x2"));

        }
        return Sb.ToString();

    }
}

}

我解决了我的问题...我只是清理、构建和重建解决方案,然后奇迹发生了。谢谢大家的帮助。