Xamarin.ios 绑定问题:在绑定类上调用基方法调用重写方法。导致无限递归

Xamarin.ios 绑定问题:在绑定类上调用基方法调用重写方法。导致无限递归,xamarin.ios,cordova,xamarin,cordova-2.0.0,Xamarin.ios,Cordova,Xamarin,Cordova 2.0.0,我正在做一个使用Cordova的MonoTouch项目。我为Cordova()创建了一个绑定 我能够很好地实例化这些类,没有失败。然而,当我试图扩展它们时,我遇到了问题。例如,如果我只是尝试扩展CDVViewController,甚至不重写任何内容,那么当我们看到实例化这个扩展类的代码时,系统会安静地退出,没有错误消息,下面是退出行 The program 'Mono' has exited with code 0 (0x0). The program '[5600] ***.vshost.ex

我正在做一个使用Cordova的MonoTouch项目。我为Cordova()创建了一个绑定

我能够很好地实例化这些类,没有失败。然而,当我试图扩展它们时,我遇到了问题。例如,如果我只是尝试扩展CDVViewController,甚至不重写任何内容,那么当我们看到实例化这个扩展类的代码时,系统会安静地退出,没有错误消息,下面是退出行

The program 'Mono' has exited with code 0 (0x0).
The program '[5600] ***.vshost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
这是我试图实例化的类

public class WebViewController : CDVViewController
{
}
这是它后面的装订

[BaseType (typeof (UIViewController))]
interface CDVViewController {
    [Export ("webView")]
    UIWebView WebView { get; set; }

    [Export ("pluginObjects")]
    NSMutableDictionary PluginObjects { get; }

    [Export ("pluginsMap")]
    NSDictionary PluginsMap { get; }

    [Export ("settings")]
    NSDictionary Settings { get; }

    [Export ("whitelist")]
    CDVWhitelist Whitelist { get; }

    [Export ("loadFromString")]
    bool LoadFromString { get; }

    [Export ("useSplashScreen")]
    bool UseSplashScreen { get; set; }

    [Export ("activityView")]
    UIActivityIndicatorView ActivityView { get; }

    [Export ("imageView")]
    UIImageView ImageView { get; }

    [Export ("wwwFolderName")]
    string WwwFolderName { get; set; }

    [Export ("startPage")]
    string StartPage { get; set; }

    [Export ("commandQueue")]
    NSObject CommandQueue { get; set; }

    [Export ("commandDelegate")]
    NSObject CommandDelegate { get; set; }

    [Export ("userAgent")]
    string UserAgent { get; }

    [Export ("printMultitaskingInfo")]
    void PrintMultitaskingInfo ();

    [Export ("createGapView")]
    void CreateGapView ();

    [Export ("newCordovaViewWithFrame:")]
    UIWebView NewCordovaView(RectangleF bounds);

    [Export ("javascriptAlert:")]
    void JavascriptAlert (string text);

    [Export ("appURLScheme")]
    string AppUrlScheme ();

    [Export ("parseInterfaceOrientations:")]
    NSArray ParseInterfaceOrientations (NSArray orientations);

    [Export ("supportsOrientation:")]
    bool SupportsOrientation (UIInterfaceOrientation orientations);

    [Export ("getCommandInstance:")]
    NSObject GetCommandInstance (string pluginName);

    [Export ("registerPlugin:withClassName:")]
    void RegisterPluginWithClassName (CDVPlugin plugin, string className);

    [Export ("URLisAllowed:")]
    bool UrlIsAllowed (NSUrl url);

    [Static] [Export ("getBundlePlist:")]
    NSDictionary GetBundlePlist (string plistName);

    [Static] [Export ("applicationDocumentsDirectory")]
    string ApplicationDocumentsDirectory ();

    // The following methods and properties come from UIWebViewDelegate, but we can't do multiple inheritance
    [Export ("webView:shouldStartLoadWithRequest:navigationType:")]
    bool ShouldStartLoad (UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType);
}
我为其构建绑定的

任何人能提供的任何帮助都将不胜感激

更新#1 这似乎是由分段错误引起的。对于其他经历过这种情况的人,如果你进入Mac并查看日志,你可能会发现同样的情况。您可以打开终端,输入
tail-f/var/log/system.log
,因为这显然是模拟器的日志所在

在我的日志中,我发现了以下内容<代码>***用于编辑应用程序名称

Mar 28 16:51:16 macmini1 com.apple.launchd.peruser.55385368[409] (UIKitApplication:com.***.***[0x5ef3][14219]): Job appears to have crashed: Segmentation fault: 11
Mar 28 16:51:16 macmini1 SpringBoard[516]: Application '***' exited abnormally with signal 11: Segmentation fault: 11
Mar 28 16:51:16 macmini1 ReportCrash[14132]: Saved crash report for ***[14219] version ??? (???) to /Users/jstarke/Library/Logs/DiagnosticReports/***_2013-03-28-165116_macmini1.crash
Mar 28 16:51:16 macmini1 ReportCrash[14132]: Removing excessive log: file://localhost/Users/jstarke/Library/Logs/DiagnosticReports/***_2013-03-28-135722_macmini1.crash
更新#2 我找到了上面提到的坠机报告。下面是最新的崩溃报告信息,包括崩溃的线程

Process:         *** [29880]
Path:            /Users/*/Library/Application Support/iPhone Simulator/*/***.app/***
Identifier:      ***
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  launchd [409]

Date/Time:       2013-03-29 11:44:48.882 -0700
OS Version:      Mac OS X Server 10.7.5 (11G63)
Report Version:  9

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000bf7fff7c

VM Regions Near 0xbf7fff7c:
    Stack                  00000000b050b000-00000000b052c000 [  132K] rw-/rwx SM=COW  
--> Stack                  00000000bc000000-00000000bf800000 [ 56.0M] ---/rwx SM=NUL  
    Stack                  00000000bf800000-00000000c0000000 [ 8192K] rw-/rwx SM=COW  

Application Specific Information:
iPhone Simulator 358.4, iPhone OS 6.0 (iPhone/10A403)


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_c.dylib             
0x954d458c szone_malloc_should_clear + 12
1   libsystem_c.dylib             
0x954d566b szone_malloc + 24
2   libsystem_c.dylib             
0x9550b962 malloc_zone_malloc + 77
3   libsystem_c.dylib             
0x9550c882 malloc + 50
4   libobjc.A.dylib               
0x041985c9 class_copyProtocolList + 157
5   CoreFoundation                
0x03f72962 __methodDescriptionForSelector + 178
6   CoreFoundation                
0x03fe65a3 -[NSObject(NSObject) methodSignatureForSelector:] + 51
7   ***                  
0x00254352 monotouch_trampoline + 82
8   ???                           
0x16c4ab0b 0 + 381987595
9   ???                           
0x16c7428c 0 + 382157452
10  ???                           
0x16c743dc 0 + 382157788
11  ***                  
0x0004cf22 mono_jit_runtime_invoke + 722
12  ***                  
0x001b03fe mono_runtime_invoke + 126
13  ***                  
0x00255166 monotouch_trampoline + 3686

Lines 8 - 13 repeat a large number of times (no additional information)

506 ???                           
0x16c4ab0b 0 + 381987595
507 ???                           
0x16c7428c 0 + 382157452
508 ???                           
0x16c743dc 0 + 382157788
509 ***
0x0004cf22 mono_jit_runtime_invoke + 722
510 ***                  
0x001b03fe mono_runtime_invoke + 126
511 ***                  
0x00255166 monotouch_trampoline + 3686
更新#3 为了获得更多信息,我决定在本地WebViewController中重写CDVViewController中的所有方法,然后从每个方法的基等价物返回值,并在该方法上设置断点,并放置一个Console.WriteLine,说明我们输入和退出了每个方法

令我惊讶的是,Update#2中出现许多重复的原因与以下事实有关:当调用
WebViewController.ShouldAutoRotateToInterfaceOrientation
时,我们称基类为
CDVViewController.ShouldAutoRotateToInterfaceOrientation
,这显然会依次调用
WebViewController.ShouldAutoRotateToInterfaceOrientation
,等等

查看我正在使用的Cordova()版本的源代码,
应该自动旋转指针FaceOrientation:
将调用
supportsOrientation:
,它将从
NSArray
返回


我看不出为什么
CDVViewController.shoulldAutorotateTointerFaceOrientation
应该调用
WebViewController.ShouldAutoRotateToInterfaceOrientation
。Xamarin或Cordova社区中有人知道吗?

如果其他人遇到与绑定相关的类似问题,我在Rolf Bjarne Kvinge()的建议下成功地解决了这个问题

事实证明,我使用的一个标志(没有真正理解它做了什么)应该对此负责。使用
b触摸
生成DLL时,
-e
标志
生成不能子类化的较小类

删除此项可能会解决您的问题,就像它为我所做的一样