Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I'm learning to use UICollectionView, and my app would crash with this exception when calling DequeueReusableCell:
“Selector invoked from objective-c on a managed object of type App.TestCell (0xC65FFA0) that has been GC'ed”
I later learned that I forgot to decorate the cell constructor with [Export]:
public TestCell (RectangleF frame) : base (frame)
In fact, the inner exception clearly shows this was the problem:
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Selector invoked from objective-c on a managed object of type App.TestCell (0x1A7D8160) that has been GC'ed ---> System.MissingMethodException: No constructor found for App.TestCell::.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) [0x000f1] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:280
Still, I think the actual exception being thrown is confusing and misleading.
The problem is supposed to be with the missing method and NOT with GC.
Is there any way to throw a more user-friendly exception?
Attached is the error I saw (as you can see, you need to _scroll_ to see the inner exception).
Created attachment 2955 [details]
MonoDevelop obscures inner exception which is the real issue
This is a complicated error condition to give good information about, historically the current message has been right most of the time (and thus helpful to whoever ran into it, a lot more than what a MissingMethodException would be), but then there are people like you, who run into it because of other bugs in your code, in which case the error message is just plain wrong.
The good knews is that we've done work to eliminate the first case (where the error message was useful) - this is currently being tested in the 6.0.6 (beta) release. Hopefully this means that we can give a better message for your case soon.
This error message was improved some time ago.