我刚刚在我的新应用程序中实现了Prism库,我使用的是NavigationService。它在Android上运行得很好,但是当我尝试在网络Mac上调试我的iOS应用程序时,我的主要方法会抛出这个异常:
Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch
Native stack trace:
0 CoreFoundation 0x00000001021f2b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010cdcf141 objc_exception_throw + 48
2 CoreFoundation 0x00000001021f6cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000102da93b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000105ba0be6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3343
5 UIKit 0x0000000105b9d793 -[UIApplication workspaceDidEndTransaction:] + 182
6 FrontBoardServices 0x000000010fae35f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
7 FrontBoardServices 0x000000010fae346d -[FBSSerialQueue _performNext] + 186
8 FrontBoardServices 0x000000010fae37f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
9 CoreFoundation 0x0000000102198c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
10 CoreFoundation 0x000000010217e0cf __CFRunLoopDoSources0 + 527
11 CoreFoundation 0x000000010217d5ff __CFRunLoopRun + 911
12 CoreFoundation 0x000000010217d016 CFRunLoopRunSpecific + 406
13 UIKit 0x0000000105b9c02f -[UIApplication _run] + 468
14 UIKit 0x0000000105ba20d4 UIApplicationMain + 159
15 ??? 0x0000000124f647fc 0x0 + 我的主要方法是:
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}AppDelegate:
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
this.LoadApplication(new Core.CitizenApp());
return base.FinishedLaunching(app, options);
}
}表格应用程序:
protected override void OnInitialized()
{
this.InitializeComponent();
NavigationService.NavigateAsync("LaunchPage");
return;
}任何帮助都将不胜感激。我有关于Xamarin、Xamarin窗体、Prism和Visual的最新更新,我不知道问题可能是什么。
发布于 2017-04-22 18:30:49
您的LaunchPage引发了异常。更新OnInitialized如下所示:
protected override async void OnInitialized()
{
try
{
TaskScheduler.UnobservedTaskException += (sender, e) => {
Logger.Log(e.Exception.ToString(), Category.Exception, Priority.High);
};
await NavigationService.NavigateAsync("LaunchPage");
}
catch(Exception e)
{
Logger.Log(e.Exception.ToString(), Category.Exception, Priority.High);
}
}这至少可以帮助您确定什么是例外。没有看到您的项目,很难说,但我可能会猜测,您使用的是IPlatformInitializer,注册的是安卓,而不是iOS,或者您依赖的是Xamarin表单依赖服务,并且依赖于Android,而不是iOS。
https://stackoverflow.com/questions/43556274
复制相似问题