xamarin app SIGSEGV错误

时间:2014-02-26 10:24:41

标签: c# xamarin.ios xamarin sigsegv

开发。

我是新的monotouch开发者。

我的应用程序正常运行此代码块但突然关闭并出现此错误。我哪里可以做错?我怎么解决?谢谢。

 NewsElement.Tapped+= delegate(object sender, EventArgs e) 
        {
            try 
            {
                News news=_news.Find(x => x.Title== _section.Elements[NewsElement._indexPath.Row].Caption.ToString());


                using(NewsDetailViewController nDVC=new NewsDetailViewController(news,_newsEnum))
                {

                    this.NavigationController.NavigationBar.BarTintColor = ExtensionMethods.ToUIColor("4BC1D2");
                    this.NavigationController.NavigationBar.TintColor=UIColor.White;
                    this.NavigationController.PushViewController (nDVC, true);  

                }
            } 
            catch 
            {

            }

        };

错误是:

mono-rt: Stacktrace:

mono-rt:   at <unknown> <0xffffffff>

mono-rt:   at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (intptr,intptr) <IL 0x00026, 0xffffffff>

mono-rt:   at MonoTouch.UIKit.UIViewController.get_NavigationController () [0x00030] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIViewController.g.cs:1595

mono-rt:   at HaberOku.MainViewController.<LoadView>m__A (object,System.EventArgs) [0x00029] in /Users/muhammetsahin/Projects/HaberOku/HaberOku/DialogViewControllers/MainViewController.cs:89

mono-rt:   at (wrapper delegate-invoke) System.EventHandler`1.invoke_void__this___object_TEventArgs (object,TEventArgs) <IL 0x00027, 0x00087>

mono-rt:   at (wrapper delegate-invoke) System.EventHandler`1.invoke_void__this___object_TEventArgs (object,TEventArgs) <IL 0x00059, 0xffffffff>

mono-rt:   at HaberOku.NewsElement.Selected (MonoTouch.Dialog.DialogViewController,MonoTouch.UIKit.UITableView,MonoTouch.Foundation.NSIndexPath) [0x00029] in /Users/muhammetsahin/Projects/HaberOku/HaberOku/Elements/NewsElement.cs:61

mono-rt:   at MonoTouch.Dialog.DialogViewController.Selected (MonoTouch.Foundation.NSIndexPath) [0x00033] in /Users/muhammetsahin/Projects/HaberOku/HaberOku/MonoTouchDialog/DialogViewController.cs:522

mono-rt:   at MonoTouch.Dialog.DialogViewController/Source.RowSelected (MonoTouch.UIKit.UITableView,MonoTouch.Foundation.NSIndexPath) [0x00021] in /Users/muhammetsahin/Projects/HaberOku/HaberOku/MonoTouchDialog/DialogViewController.cs:368

mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <IL 0x0005a, 0xffffffff>

mono-rt:   at <unknown> <0xffffffff>

mono-rt:   at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>

mono-rt:   at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38

mono-rt:   at HaberOku.Application.Main (string[]) [0x00009] in /Users/muhammetsahin/Projects/HaberOku/HaberOku/Main.cs:17

mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

mono-rt: 
Native stacktrace:


mono-rt: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

2 个答案:

答案 0 :(得分:3)

这是一个非常奇怪的模式。一旦块完成,它将处理nDVC,即使您刚刚将nDVC推入导航堆栈并仍在使用它。尝试删除using(),以免nDVC过早处理。

            using(NewsDetailViewController nDVC=new NewsDetailViewController(news,_newsEnum))
            {
                this.NavigationController.NavigationBar.BarTintColor = ExtensionMethods.ToUIColor("4BC1D2");
                this.NavigationController.NavigationBar.TintColor=UIColor.White;
                this.NavigationController.PushViewController (nDVC, true);  
            }

答案 1 :(得分:0)

当我在执行委托时引用不再存在的对象时,我也遇到了这种错误。

所以也许你可以尝试确保你正在调用的对象仍然可用/没有被垃圾收集。尝试发送或进行空检查。