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.
Created attachment 4528 [details]
Test Project demonstrating the issue
In Xamarin.iOS 6.4, I am no longer able to use generic subclasses of UIViewController more than once. When I try to create another instance of the generic ViewController of a different type, I get the following error:
Unable to cast object of type 'GenericsTest.SalesDocumentView' (Objective-C type: 'GenericsTest.SalesDocumentView') to type 'GenericsTest.CustomView`1[GenericsTest.Customer]'.
Method: GenericsTest.CustomView`1<GenericsTest.Customer>:LoadView ()
I've attached an example project which demonstrates my issue. I push and instance of CustomerViewController onto the navigation stack, then tap a button on that view to push an instance of SalesDocumentViewController. The error is thrown when the SalesDocumentViewController is created.
Both CustomerViewController and SalesDocumentViewController inherit from CustomView<T> (which inherits from UIViewController), themselves being CustomView<Customer> and CustomView<SalesDocument>.
This error only occurs on devices. I've tried turning off "Enable Generic Value Type Sharing", if that matters.
Is this intended? This sort of structure worked in prior versions.
*** This bug has been marked as a duplicate of bug 13518 ***