Hi, Yes, you must somehow ensure that the object is reachable for the GC. The most generic fix is to store it as a class variable somewhere.
One possible reason it's not happening for you is that it's only happening under low memory conditions (in which case objects might be freed when you don't expect them too). Rolf On Wed, Feb 22, 2012 at 11:49 PM, Nic Wise <[email protected]> wrote: > possibly. Any way to stop this happening? Don't let it go out of scope? > > On Thu, Feb 23, 2012 at 11:32, Rolf Bjarne Kvinge <[email protected]> > wrote: > > Hi, > > > > Most likely an UploadStatusViewController has been freed too early by the > > GC, in particular if it's happening randomly. > > > > Rolf > > > > On Wed, Feb 22, 2012 at 10:56 PM, Nic Wise <[email protected]> > wrote: > >> > >> Hi there > >> > >> I'm getting this error back from various users of my app (I"ve not > >> seen it myself) > >> > >> Exception: System.Exception: Selector invoked from objective-c on a > >> managed object (0x56B51D0) that has been GC'ed ---> > >> System.MissingMethodException: No constructor found for > >> MobileAgent.UploadStatusViewController::.ctor(System.IntPtr) > >> at System.Activator.CreateInstance (System.Type type, BindingFlags > >> bindingAttr, System.Reflection.Binder binder, System.Object[] args, > >> System.Globalization.CultureInfo culture, System.Object[] > >> activationAttributes) [0x00000] in <filename unknown>:0 > >> at System.Activator.CreateInstance (System.Type type, > >> System.Object[] args, System.Object[] activationAttributes) [0x00000] > >> in <filename unknown>:0 > >> at System.Activator.CreateInstance (System.Type type, > >> System.Object[] args) [0x00000] in <filename unknown>:0 > >> at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, > >> IntPtr klass) [0x00000] in <filename unknown>:0 > >> --- End of inner exception stack trace --- > >> at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, > >> IntPtr klass) [0x00000] in <filename unknown>:0 > >> at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] > >> in <filename unknown>:0 > >> at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr) > >> [0x00000] in <filename unknown>:0 > >> at (wrapper native-to-managed) > >> MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr) > >> at MonoTouch.UIKit.UIViewController.DismissModalViewControllerAnimated > >> (Boolean animated) [0x00000] in <filename unknown>:0 > >> at MobileAgent.AddExpenseDialogViewController.Save (System.Object > >> sender, System.EventArgs e) [0x00000] in <filename unknown>:0 > >> at MonoTouch.UIKit.UIBarButtonItem+Callback.Call > >> (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename > >> unknown>:0 > >> at MonoTouch.UIKit.UIApplication.Main (System.String[] args, > >> System.String principalClassName, System.String delegateClassName) > >> [0x00000] in <filename unknown>:0 > >> at MobileAgent.Application.Main (System.String[] args) [0x00000] in > >> <filename unknown>:0 > >> 20120222/214652: StackTrace: at > >> MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr > >> klass) [0x00000] in <filename unknown>:0 > >> at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] > >> in <filename unknown>:0 > >> at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr) > >> [0x00000] in <filename unknown>:0 > >> at (wrapper native-to-managed) > >> MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr) > >> at MonoTouch.UIKit.UIViewController.DismissModalViewControllerAnimated > >> (Boolean animated) [0x00000] in <filename unknown>:0 > >> at MobileAgent.AddExpenseDialogViewController.Save (System.Object > >> sender, System.EventArgs e) [0x00000] in <filename unknown>:0 > >> at MonoTouch.UIKit.UIBarButtonItem+Callback.Call > >> (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename > >> unknown>:0 > >> at MonoTouch.UIKit.UIApplication.Main (System.String[] args, > >> System.String principalClassName, System.String delegateClassName) > >> [0x00000] in <filename unknown>:0 > >> at MobileAgent.Application.Main (System.String[] args) [0x00000] in > >> <filename unknown>:0 > >> > >> > >> The class which is having the problem is this one: > >> > >> public class UploadStatusViewController : UIViewController > >> { > >> > >> public UploadStatusViewController (RectangleF bounds, int > >> lines) : base() > >> { > >> > >> etc - it only has one constructor at this level. > >> > >> I've not done an (IntPtr) constructor for it, so I assumed it would > >> take UIViewController's one.... Bug, or my problem? > >> > >> Thanks > >> > >> Nic > >> > >> -- > >> Nic Wise > >> t. +44 7788 592 806 | @fastchicken | > http://www.linkedin.com/in/nicwise > >> b. http://www.fastchicken.co.nz/ > >> > >> Nearest Bus: find when the next bus is coming to your stop. > >> http://goo.gl/Vcz1p > >> mobileAgent (for FreeAgent): get your accounts in your pocket. > >> http://goo.gl/IuBU > >> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa > >> London Bike App: Find the nearest Boris Bike, and get riding! > >> http://goo.gl/Icp2 > >> _______________________________________________ > >> MonoTouch mailing list > >> [email protected] > >> http://lists.ximian.com/mailman/listinfo/monotouch > > > > > > > > -- > Nic Wise > t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise > b. http://www.fastchicken.co.nz/ > > Nearest Bus: find when the next bus is coming to your stop. > http://goo.gl/Vcz1p > mobileAgent (for FreeAgent): get your accounts in your pocket. > http://goo.gl/IuBU > Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa > London Bike App: Find the nearest Boris Bike, and get riding! > http://goo.gl/Icp2 >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
