This work-around will make your code work, but will cause your object to
surface with no previous managed state, which
is very very bad.
The solution is trying to keep a reference to it from known live objects.

On Mon, Aug 20, 2012 at 5:45 PM, Nic Wise <n...@fastchicken.co.nz> wrote:

> Make a constructor which takes an IntPtr as the single param. But it
> may cause other issues, I'm not sure....
>
> On Mon, Aug 20, 2012 at 9:39 PM, Dotnet Projects
> <coderproje...@gmail.com> wrote:
> > I have to keep all Viewcontroller in the memory. Is there anything else I
> > can do?
> >
> > Thanks
> > Art
> >
> >
> > On Mon, Aug 20, 2012 at 3:19 PM, Nic Wise <n...@fastchicken.co.nz>
> wrote:
> >>
> >> I'm pretty sure this is a known problem - you have let the managed
> >> version (C# version) go out of scope, and it's been garbage collected.
> >> The Cocoa side wants to use the object, so the runtime trys to make
> >> the managed version again - but it can't as it doesn't have an IntPtr
> >> constructor.
> >>
> >> If you can work out which object is the problem, try keeping an
> >> explicit reference to it.
> >>
> >> On Mon, Aug 20, 2012 at 8:04 PM, Dotnet Projects
> >> <coderproje...@gmail.com> wrote:
> >> > I am getting the error from MonoTouch..DialogViewController too.
> >> >
> >> > it might be related to the linker options I am using
> >> >
> >> > --linkskip=mscorlib -aot "nimt-trampolines=512"
> >> >
> >> >
> >> >
> >> >   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.UIApplication.Main (System.String[] args,
> >> > System.String
> >> > principalClassName, System.String delegateClassName) [0x00000] in
> >> > <filename
> >> > unknown>:0
> >> >   at Application.Main (System.String[] args) [0x00000] in <filename
> >> > unknown>:0 System.Exception: Selector invoked from objective-c on a
> >> > managed
> >> > object (0x73D1AD0) that has been GC'ed --->
> >> > System.MissingMethodException:
> >> > No constructor found for
> >> > MonoTouch.Dialog.DialogViewController::.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.UIApplication.Main (System.String[] args,
> >> > System.String
> >> > principalClassName, System.String delegateClassName) [0x00000] in
> >> > <filename
> >> > unknown>:0
> >> >   at Application.Main (System.String[] args) [0x00000] in <filename
> >> > unknown>:0 System.Exception: Selector invoked from objective-c on a
> >> > managed
> >> > object (0x73D1AD0) that has been GC'ed --->
> >> > System.MissingMethodException:
> >> > No constructor found for
> >> > MonoTouch.Dialog.DialogViewController::.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.UIApplication.Main (System.String[] args,
> >> > System.String
> >> > principalClassName, System.String delegateClassName) [0x00000] in
> >> > <filename
> >> > unknown>:0
> >> >   at Application.Main (System.String[] args) [0x00000] in <filename
> >> > unknown>:0
> >> >
> >> >
> >> > On Mon, Aug 20, 2012 at 1:53 PM, Dotnet Projects
> >> > <coderproje...@gmail.com>
> >> > wrote:
> >> >>
> >> >> Thanks for the reply.
> >> >>
> >> >> I am not using SGEN but I am using following linker options
> >> >>
> >> >> --linkskip=mscorlib -aot "nimt-trampolines=512"
> >> >>
> >> >> It only happens in release mode (device). Unfortunately I cannot
> repeat
> >> >> it
> >> >> but I get logs from customer and I get same errors any where I use.
> >> >>
> >> >> myUIVIewControler p = new myUIVIewControler();
> >> >>
> >> >> Art
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On Mon, Aug 20, 2012 at 8:11 AM, René Ruppert <
> rene.rupp...@gmail.com>
> >> >> wrote:
> >> >>>
> >> >>> The code above (the first example with the local PenColor) should
> NOT
> >> >>> crash. PresentModalViewController is supposed to hold a managed
> >> >>> reference.
> >> >>> If not, I'd consider that a bug.
> >> >>> I'm using code like that all the time and do not get any crashes.
> I'm
> >> >>> using SGen but have the experimental ref count system OFF.
> >> >>> But if you're using XIBs, your controllers should really have the
> >> >>> IntPtr
> >> >>> constructor, as far as I know.
> >> >>>
> >> >>> René
> >> >>>
> >> >>>
> >> >>> 2012/8/19 rnendel11 <rnende...@gmail.com>
> >> >>>>
> >> >>>> Because you're declaring at class scope vs. method scope.  I'm
> >> >>>> guessing
> >> >>>> you
> >> >>>> have SGen enabled and possibly the experimental reference count
> >> >>>> option
> >> >>>> as
> >> >>>> well?
> >> >>>>
> >> >>>> I stopped using SGen myself, had GC issues and crashes.  If you
> have
> >> >>>> those
> >> >>>> options enabled, try without them enabled.  Also, I'm not entirely
> >> >>>> sure
> >> >>>> of
> >> >>>> the details, but there are additional build parameters you have to
> >> >>>> define
> >> >>>> when SGen is enabled.
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>> --
> >> >>>> View this message in context:
> >> >>>>
> >> >>>>
> http://monotouch.2284126.n4.nabble.com/GC-ed-System-MissingMethodException-tp4656569p4656575.html
> >> >>>> Sent from the MonoTouch mailing list archive at Nabble.com.
> >> >>>> _______________________________________________
> >> >>>> MonoTouch mailing list
> >> >>>> MonoTouch@lists.ximian.com
> >> >>>> http://lists.ximian.com/mailman/listinfo/monotouch
> >> >>>
> >> >>>
> >> >>>
> >> >>> _______________________________________________
> >> >>> MonoTouch mailing list
> >> >>> MonoTouch@lists.ximian.com
> >> >>> http://lists.ximian.com/mailman/listinfo/monotouch
> >> >>>
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > MonoTouch mailing list
> >> > MonoTouch@lists.ximian.com
> >> > 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/
> >>
> >> 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
> >> Earnest: Self-employed? Track your business expenses and income.
> >> http://earnestapp.com
> >> Nearest Bus: find when the next bus is coming to your stop.
> >> http://goo.gl/Vcz1p
> >> London Bike App: Find the nearest Boris Bike, and get riding!
> >> http://goo.gl/Icp2
> >
> >
>
>
>
> --
> Nic Wise
> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
> b. http://www.fastchicken.co.nz/
>
> 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
> Earnest: Self-employed? Track your business expenses and income.
> http://earnestapp.com
> Nearest Bus: find when the next bus is coming to your stop.
> http://goo.gl/Vcz1p
> London Bike App: Find the nearest Boris Bike, and get riding!
> http://goo.gl/Icp2
> _______________________________________________
> MonoTouch mailing list
> MonoTouch@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to