Xamarin Android调试:没有运行兼容的代码 [英] Xamarin Android debugging: No compatible code running

查看:190
本文介绍了Xamarin Android调试:没有运行兼容的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我正在使用VS 2017.3开发Xamarin.Forms应用程序.我试图诊断我的代码在哪里以及为什么发生异常.

I am using VS 2017.3 to develop Xamarin.Forms application. I am trying to diagnose where and why an Exception occur on my code.

我可以使用SDK Android仿真器(HAX x86)成功地部署运行和调试我的应用程序.

I can successfully deploy run and debug my application using the SDK Android Emulator (HAX x86).

但是,如果发生异常,我将看不到有关该异常的任何信息,请参阅所附图片,设置.

However in case an Exception occur I can not see any information about the Exception, see attached picture, settings.

问题

在Android调试中这是正常现象,还是缺少我的东西?

Is this normal in Android debugging, or missing I something?

...以及我的构建设置:

...and my build settings:

推荐答案

我想扩展@Uraitz的答案,因为它可以帮助我找出问题所在.

I wanted to expand on @Uraitz's answer because it helped me figure out the problem.

首先,正如他解释的那样,您将要在活动中添加事件处理程序,如以下代码所示:

First, as he explains, you will want to add an event handler in your activity, as shown in the following code:

    protected override void OnCreate(Bundle savedInstanceState)
    {
        ...
        //subscribe to unhandled event  
        AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
        ...
    }

    private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine(e.ToString());
    }

就我而言,我在CurrentDomainUnhandledException内放置了一个断点,以便可以检查异常.

In my case I put a breakpoint inside CurrentDomainUnhandledException so I could inspect the exception.

但是,即使有那个断点,我也运行了我的代码,仍然遇到一个令人困惑的no-callstack错误.

However, even with that breakpoint in there, I ran my code and still got a confusing no-callstack error.

在这一点上,我认为解决方案无效.实际上是这样,但是我必须多次单击播放(继续)"按钮,然后我的应用才能达到断点:

At this point I thought the solution wasn't working. In fact it is, but I had to click the Play (continue) button multiple times before my app would hit the breakpoint:

单击该按钮两次后 ,我终于找到了断点:

After clicking that button two times, I finally hit the breakpoint:

如果要在调试器中获取调用堆栈,则必须先进行几个层次的深入研究,但可以通过查看事件args参数来实现.

If you want to get the callstack in the debugger, you will have to dive in a few levels before it is available, but you can do so by looking at the event args parameter.

故事的寓意是-如果您添加了事件处理程序,但仍然没有达到断点(或看到输出),请继续单击继续"按钮!

The moral of the story is - if you have added the event handler but you still aren't hitting the breakpoint (or seeing output) - keep clicking the Continue button!

这篇关于Xamarin Android调试:没有运行兼容的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆