Bug 28346 - [iOS] Pushing a ViewController with baseType CustomViewController causes UIApplication.Main to throw "System.NotSupportedException: Operation is not supported" exception when deploying to device.
Summary: [iOS] Pushing a ViewController with baseType CustomViewController causes UIAp...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.6.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-03-23 18:58 UTC by Kent Green [MSFT]
Modified: 2015-03-24 14:54 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Logs from my repo of the issue (156.46 KB, application/zip)
2015-03-23 18:58 UTC, Kent Green [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description Kent Green [MSFT] 2015-03-23 18:58:26 UTC
Created attachment 10462 [details]
Logs from my repo of the issue

---Overview---
From this desk case:
https://kb.xamarin.com/agent/case/135812

Possibly related forum thread:
"NotSupportedException on device but not on simulator on DequeueReusableCell"
https://forums.xamarin.com/discussion/comment/111506/#Comment_111506

Customer reports that pushing a ViewController with baseType CustomViewController causes UIApplication.Main to throw the following exception when deploying to device: 

> System.NotSupportedException: Operation is not supported.
>  at ObjCRuntime.Runtime.GetGenericMethodDirect (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00035] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:248
>  at ObjCRuntime.Runtime.get_generic_method_direct (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:184
>  at at (wrapper native-to-managed) ObjCRuntime.Runtime:get_generic_method_direct (intptr,intptr,intptr,int,intptr*)
>  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
>  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
>  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45
>  at Xamarin.Bug.Application.Main (System.String[] args) [0x00008] in /Users/kentgreen/Downloads/Xamarin.Bug/Main.cs:14

---Steps to reproduce---
I was able to reproduce the issue with the customer's sample and will attach it shortly as a private attachment.

---Build information---
=== Xamarin Studio ===

Version 5.8 (build 443)
Installation UUID: 8ef63a7c-1b18-40de-a334-7f78777fcb55
Runtime:
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.0.2 (Business Edition)
Hash: ccfcd59
Branch: 
Build date: 2015-03-10 02:20:32-0400

=== Xamarin.Android ===

Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/kentgreen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

=== Operating System ===

Mac OS X 10.10.2
Darwin Kents-Macbook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0
    Mon Dec 22 23:10:38 PST 2014
    root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64

---Additional Info---
Adding logs from my reproduction of the issue.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-03-24 09:43:39 UTC
Fixed.

maccore/master: 3085500fccc3b58e34d20ddb8a2a0a81768e8f6d
maccore/macios-cycle5: b8c8d120727eef83362238f929d15f2215299585

There are two workarounds:

1. Don't use types that derive from generic types in storyboards/xibs/etc.
2. In the type that derives from the generic type: override any methods already overridden (from an iOS type, such as UITableViewController) in the generic type.

  Example: in the test case, GenericViewController<T> overrides ViewDidLoad. By also overriding ViewDidLoad in DetailViewController, the problem goes away:

	public override void ViewDidLoad ()
	{
		base.ViewDidLoad ();
	}
Comment 4 Ricardo López Rey 2015-03-24 11:50:09 UTC
Hi Rolf,

Thanks for quick response to the bug...


There is only one thing that I couldn't catch.  is this bug going to be fixed in next Xamarin's releases? or they are never being fixed and workarounds will be the only solution?


Please let me know and again thank you so much.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-03-24 12:11:43 UTC
@Ricardo, it'll be fixed in the next major release (Xamarin.iOS 8.10).
Comment 6 Ricardo López Rey 2015-03-24 14:54:51 UTC
Nice!! Thank you so much...