Hi Adam

You really need a reply from Rolf or Sebastian, but they are in Boston
at the moment at the (annual?) company meetup. I've CCed them, but I
dont know how much spare time they have this week.

So, just so this doesn't drop off the bottom of the list, this SO item
from Miguel explains it well:

http://stackoverflow.com/questions/5623223/no-constructor-found-for-viewcontroller-ctorsystem-intptr

I suspect that it might be a case where you need to keep a reference
to the object in a class-local variable, rather than a method-local
one or just assigning it to a (obj-c?) object.

I've never really implemented them, tho maybe I should :). I used to
have the same exceptions as this, but I've not seen it in live debug
logs for ages - it's possible that the GC got fixed (or improved)

Drop the list an email back if that doesn't answer your question

Cheers

Nic

On Fri, Jul 27, 2012 at 8:10 PM, Adam Kemp <[email protected]> wrote:
> I'm hitting a crash when receiving memory warnings in some situations. In
> one view controller (A) we are handling the memory warning by calling
> Dispose() on another view controller (B) which is no longer necessary.
> Unfortunately, something later on during the process of the (native)
> memory warning handling code is trying to call a method in view controller
> B, and it's trying to construct a managed object to do so. This causes an
> exception because I don't have a constructor which takes an IntPtr so the
> runtime can't construct the managed object.
>
> I know that if implementing the IntPtr constructor the crash doesn't
> occur. I also know that it goes away if I remove the call to Dispose, but
> I don't think that's a guaranteed fix since the object could still be
> GCed. I'm looking for the "right" fix, but I have several unanswered
> questions about what is going on that I need to find an answer to in order
> to find it.
>
> The first question is what method is being called on view controller B,
> and why is it wanting a managed object to call that method? I don't have
> an override for DidReceiveMemoryWarning or ViewDidUnload. In fact, the
> only override in that view controller (which inherits directly from
> UITableViewController) is ViewDidLoad. The exception tells me "Selector
> invoked from objective-c on a managed object (0xB9E72D0) that has been
> GC'ed", but it won't tell me which selector was invoked. In a simpler test
> case that I created I could only reproduce the crash if I overrode either
> DidReceiveMemoryWarning or ViewDidUnload, but in my full application I get
> the crash even though I haven't implemented either. I don't understand
> why. Is there a trick to figuring out which method is being invoked when
> this exception occurs?
>
> The second question is what are the rules for when we are expected to
> implement the IntPtr constructor for classes that inherit from NSObject? I
> don't want to blindly add it to every class, especially since in some
> cases it probably can't be implemented in a sane way at all (the Dispose
> method might have released resources that you can't get back without
> arguments from a real constructor). Is there some rule for this? Does my
> situation fit that rule?
>
> Thanks.
> --
> Adam Kemp
> [email protected]
> (512) 683-6058
> _______________________________________________
> 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/

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
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to