将iOS应用程序升级到Xamarin Unified API

时间:2015-09-21 18:53:59

标签: c# ios xamarin xamarin.ios

尝试使用Xamarin Studio中的自动升级工具启动我升级到统一API的应用时出现异常。我可以在iPhone模拟器中看到启动画面显示大约一秒钟,然后在Main方法中抛出以下异常。

Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Native stack trace:
    0   CoreFoundation                      0x00940a94 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x087ffe02 objc_exception_throw + 50
    2   CoreFoundation                      0x007ee3a1 -[__NSArrayM insertObject:atIndex:] + 881
    3   CoreFoundation                      0x007ee001 -[__NSArrayM addObject:] + 65
    4   UIKit                               0x0342e9b6 -[UINavigationController _navigationItems] + 341
    5   UIKit                               0x0342c3ac -[UINavigationController initWithCoder:] + 1009
    6   UIKit                               0x0364c834 -[UIClassSwapper initWithCoder:] + 279
    7   UIKit                               0x03846e99 UINibDecoderDecodeObjectForValue + 739
    8   UIKit                               0x03846bae -[UINibDecoder decodeObjectForKey:] + 320
    9   UIKit                               0x0333a812 -[UINavigationBar initWithCoder:] + 472
    10  UIKit                               0x03846e99 UINibDecoderDecodeObjectForValue + 739
    11  UIKit                               0x03846bae -[UINibDecoder decodeObjectForKey:] + 320
    12  UIKit                               0x0332f9a9 -[UINavigationItem initWithCoder:] + 899
    13  UIKit                               0x03846e99 UINibDecoderDecodeObjectForValue + 739
    14  UIKit                               0x03846bae -[UINibDecoder decodeObjectForKey:] + 320
    15  UIKit                               0x033f217e -[UIViewController initWithCoder:] + 528
    16  UIKit                               0x03455f5e -[UITabBarController initWithCoder:] + 68
    17  UIKit                               0x0364c834 -[UIClassSwapper initWithCoder:] + 279
    18  UIKit                               0x03846e99 UINibDecoderDecodeObjectForValue + 739
    19  UIKit                               0x03846bae -[UINibDecoder decodeObjectForKey:] + 320
    20  UIKit                               0x0364c403 -[UIRuntimeConnection initWithCoder:] + 148
    21  UIKit                               0x03846e99 UINibDecoderDecodeObjectForValue + 739
    22  UIKit                               0x038470aa UINibDecoderDecodeObjectForValue + 1268
    23  UIKit                               0x03846bae -[UINibDecoder decodeObjectForKey:] + 320
    24  UIKit                               0x0364b43d -[UINib instantiateWithOwner:options:] + 1411
    25  UIKit                               0x039f4ace -[UIStoryboard instantiateViewControllerWithIdentifier:] + 220
    26  UIKit                               0x039f4c5b -[UIStoryboard instantiateInitialViewController] + 78
    27  UIKit                               0x032355e7 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 99
    28  UIKit                               0x03235964 -[UIApplication _loadMainInterfaceFile] + 292
    29  UIKit                               0x03233d35 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1575
    30  UIKit                               0x03257905 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3171 + 68
    31  UIKit                               0x03230bae -[UIApplication workspaceDidEndTransaction:] + 163
    32  FrontBoardServices                  0x0b013ccc __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
    33  FrontBoardServices                  0x0b0137a3 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
    34  FrontBoardServices                  0x0b0311cb -[FBSSerialQueue _performNext] + 184
    35  FrontBoardServices                  0x0b031602 -[FBSSerialQueue _performNextFromRunLoopSource] + 52
    36  FrontBoardServices                  0x0b0308fe FBSSerialQueueRunLoopSourceHandler + 33
    37  CoreFoundation                      0x0085ae7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    38  CoreFoundation                      0x00850b0b __CFRunLoopDoSources0 + 523
    39  CoreFoundation                      0x0084ff28 __CFRunLoopRun + 1032
    40  CoreFoundation                      0x0084f866 CFRunLoopRunSpecific + 470
    41  CoreFoundation                      0x0084f67b CFRunLoopRunInMode + 123
    42  UIKit                               0x03230497 -[UIApplication _run] + 540
    43  UIKit                               0x03235cc1 UIApplicationMain + 160
    44  ???                                 0x17eb7288 0x0 + 401306248
    45  ???                                 0x17eb7080 0x0 + 401305728
    46  ???                                 0x17eb5210 0x0 + 401297936
    47  ???                                 0x17eb4f48 0x0 + 401297224
    48  ???                                 0x17eb50d8 0x0 + 401297624
    49  myAppiOS                         0x00207d9b mono_jit_runtime_invoke + 715
    50  myAppiOS                         0x002a66ef mono_runtime_invoke + 127
    51  myAppiOS                         0x002ab8e1 mono_runtime_exec_main + 401
    52  myAppiOS                         0x002ab697 mono_runtime_run_main + 711
    53  myAppiOS                         0x00167fad mono_jit_exec + 93
    54  myAppiOS                         0x00384bd1 xamarin_main + 2497
    55  myAppiOS                         0x00385562 main + 114
    56  libdyld.dylib                       0x08cd9a21 start + 1
    57  ???                                 0x00000003 0x0 + 3

这是默认的Main方法:

using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace myAppiOS
{
    public class Application
    {
        // This is the main entry point of the application.
        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");
        }
    }
}

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我只有分享的疑难解答提示。

问题出在StackTrace的第3行:

  

2 CoreFoundation 0x007ee3a1 - [__ NSArrayM    insertObject:atIndex :] + 881

很明显,你正在添加一个项目, libobjc.A.dylib 这个东西正在陷入困境:

  

1 libobjc.A.dylib 0x087ffe02   objc_exception_throw + 50       2

为了诊断根本原因,需要经典的ASP故障排除方法。 Debug.Print语句无处不在!

您必须在代码中搜索要将项目添加到集合的位置。那个地方可能会在instantiateViewControllerWithIdentifier电话中。

因为在您可以单步执行代码之前抛出异常,唯一的其他选项(除了内存转储调试)是注释掉或Debug.Print所有调用以缩小问题范围!一个接一个:(

这是一个PITA和I do empathize with you。我认为它是由于根据错误消息添加了一个空对象对象不能为零

它可能是任何东西,并且添加null可能是另一个问题的症状。 也许您添加的项目太大,可能超出了数组的范围,也许您只需要清理解决方案并重新部署。

如果您可以超越UIApplication.Main (args, null, "AppDelegate");,也许尝试启用异常可能会有所帮助,例如:https://stackoverflow.com/a/32754919/495455