Bug 11177 - ExportAttribute causing a thrown exception if used on members of generic activities
Summary: ExportAttribute causing a thrown exception if used on members of generic acti...
Status: RESOLVED DUPLICATE of bug 10135
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.4.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2013-03-15 07:50 UTC by Dimitar Dobrev
Modified: 2013-06-24 12:10 UTC (History)
3 users (show)

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

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 DUPLICATE of bug 10135

Description Dimitar Dobrev 2013-03-15 07:50:41 UTC
Steps to reproduce:

1. Open the sample for ExportAttribute (https://github.com/xamarin/monodroid-samples/tree/master/ExportAttribute/ExportAttributeTest);
2. Open MainActivity.cs and change Activity1 to Activity1<T>;
3. Add a new class Activity2 : Activity<string> and move the attribute from Activity1<T> to Activity2, i.e.:
    [Activity (Label = "ExportAttributeTest", MainLauncher = true)]
    public class Activity2 : Activity1<string>
    {     
    }
4. Start the sample.

Expected results:
It loads and works as before.

Actual results:
Unhandled Exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

>	0xE0 in System.Reflection.MonoMethod.Invoke at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:236	C#
 	0x6 in System.Reflection.MethodBase.Invoke at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:98	C#
 	0x7E in Android.Runtime.JNIEnv.CreateDynamicCallback at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:78	C#
 	0x1E1 in Android.Runtime.JNIEnv.RegisterJniNatives at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:119	C#


Note: I'm not sure if this is a bug, or a limitation that cannot be overcome. I can easily work around it so I'm just letting you know.
Comment 1 Dimitar Dobrev 2013-03-21 06:57:28 UTC
Any comment on this bug?
Comment 2 Jonathan Pryor 2013-06-24 12:10:19 UTC
This was a previously undocumented limitation: generic C# types cannot declare [Export] or [ExportField] methods, because the method may potentially be invoked from the Java-side, from which there is no known C#-side type information. (Rephrased, we'd be trying to lookup and invoke Activity<T>.MyButton_OnClick(), and there's no way of knowing what `T` should be at that point in time.)

This limitation is now documented at:

http://docs.xamarin.com/guides/android/advanced_topics/limitations#2.2.generic-c-classes

*** This bug has been marked as a duplicate of bug 10135 ***