Bug 5562 - When deriving from FrameLayout, overriding RequestLayout method throws fatal exception
Summary: When deriving from FrameLayout, overriding RequestLayout method throws fatal ...
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2012-06-06 23:35 UTC by David
Modified: 2016-09-02 20:05 UTC (History)
5 users (show)

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


Attachments
A class which derives from FrameLayout (711 bytes, application/octet-stream)
2012-06-06 23:35 UTC, David
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 ANSWERED

Description David 2012-06-06 23:35:19 UTC
Created attachment 2027 [details]
A class which derives from FrameLayout

I have included as an attachment a class which derives from FrameLayout.

When I use this class in my AXML (Main.axml), it causes a fatal exception to be thrown.

The text of the exception follows:

System.NotSupportedException: Unable to activate instance of type DataFlow.MyTestLayout from native handle 44e8c540 ---> System.Exception: No constructor found for DataFlow.MyTestLayout::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
  at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00033] in /Users/builder/data/lanes/monodroid-mac-4.2-series/bb1beee2/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:241
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x001c2] in /Users/builder/data/lanes/monodroid-mac-4.2-series/bb1beee2/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:226
  --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (intptr,Android.Runtime.JniHandleOwnership,System.Type) [0x001df] in /Users/builder/data/lanes/monodroid-mac-4.2-series/bb1beee2/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:229
  at Java.Lang.Object.GetObject (intptr,Android.Runtime.JniHandleOwnership,System.Type) [0x000a5] in /Users/builder/data/lanes/monodroid-mac-4.2-series/bb1beee2/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:226
  at Java.Lang.Object._GetObject<Android.Views.View> (intptr,Android.Runtime.JniHandleOwnership) <0x00127>
  at Java.Lang.Object.GetObject<Android.Views.View> (intptr,Android.Runtime.JniHandleOwnership) <0x00073>
  at Android.Views.View.n_RequestLayout (intptr,intptr) [0x00000] in /Users/builder/data/lanes/monodroid-mac-4.2-series/bb1beee2/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Views.View.cs:8106
  at (wrapper dynamic-method) object.1da015ad-e6f8-40b5-9530-3ff133dd1158 (intptr,intptr) <IL 0x0000c, 0x0002b>
  

I am using MonoDevelop 3.0.1 and Mono for Android: 4.2.1.196198126
Comment 1 Jonathan Pobst 2012-06-07 00:43:53 UTC
Try creating the constructor it's asking for, and have it simply call it's base:

public MyTestLayout (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer) : base (javaReference, transfer)
{
}