为什么我的 Xamarin.iOS 应用始终在 Application 类级别引发其 null 异常?

Why does my Xamarin.iOS app always throw its null exceptions at the Application class level?

提问人:aufty 提问时间:2/16/2017 最后编辑:aufty 更新时间:2/24/2017 访问量:1854

问:

问题

如果我的代码中的某处存在 null 异常(或各种异常),则 Visual Studio 不会在实际发生 null 引用的地方引发,而是会在此处暂停代码:

public class Application
{
    // This is the main entry point of the application.
    static void Main(string[] args)
    {
        // This is where the application breaks on exception
        UIApplication.Main(args, null, "AppDelegate");
    }
}

在编写代码时,我可能应该更加小心,但是当应用程序没有破坏空引用实际发生的地方时,调试问题会非常困难。在这里打破什么也没告诉我。是否有可能解决这个问题?

堆栈跟踪示例

Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at AirlineChoice.iOS.Application.Main (System.String[] args) [0x00001] in D:\Development\Airline Choice Suite\Source Code\Development\Airline Choice Mobile\AirlineChoice\AirlineChoice.iOS\Main.cs:12 
2017-02-22 16:15:11.780 AirlineChoice.iOS[7647:100649] Unhandled managed exception:
The method or operation is not implemented. (System.NotImplementedException)
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at AirlineChoice.iOS.Application.Main (System.String[] args) [0x00001] in D:\Development\Airline Choice Suite\Source Code\Development\Airline Choice Mobile\AirlineChoice\AirlineChoice.iOS\Main.cs:12 
C# Xamarin Xamarin.iOS NullReferenceException

评论

1赞 Gusman 2/16/2017
修改异常的 StackTrace,它应该包含引发它的调用。
0赞 BytesGuy 2/17/2017
你能提供堆栈跟踪吗?它可能会提供一些关于原因的线索
0赞 aufty 2/23/2017
@BytesGuy,我添加了堆栈跟踪的示例。这不仅仅是 null 异常。
0赞 Scott R. Frost 10/18/2018
我目前(2018 年 10 月)遇到了同样的问题,所以还没有解决
0赞 babaislove 2/5/2020
有人找到解决方案了吗?谢谢!

答: 暂无答案