How to avoid TargetInvocationException when calling constructor of custom view which loaded dynamically by Xamarin.Android Application comiled by VS 2019/Xamarin.
On Visual Studio 2017/Xamarin.Android, it is possible to create custom view in class library assembly by executing Activator.Activator.CreateInstance method. But On Visual Studio 2019/Xamarin.Android, TargetInvocationException (no java peer type found) are thrown.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: Cannot create instance of type 'ClassLibrary.ButtonEx': no Java peer type found.
at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType)
at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType)
at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters)
at Android.Widget.Button..ctor (Android.Content.Context context)
at ClassLibrary.ButtonEx..ctor (Android.Content.Context context)
Details: 1655173
So, I need help to avoid TargetInvocationException in this case.