I am developing a Xamarin.Android WebView application, and in an attempt to use Reflection to implement some AJAX methods, I have noticed that both Object.GetType
and typeof
always return System.RuntimeType
.
This happens regardless of what I pass to them - it happens when I pass string
, int
, MyClass
, etc to typeof, as well as when I call GetType on instances of these classes.
Minimum runnable code is trivial:
private class HybridWebViewClient : WebViewClient
{
public static type Test() {
Log.Debug("TypeDebug", typeof(string));
Log.Debug("TypeDebug", typeof(bool));
Log.Debug("TypeDebug", typeof(MyClass));
Log.Debug("TypeDebug", "test".GetType());
Log.Debug("TypeDebug", (34).GetType());
Log.Debug("TypeDebug", (new MyClass()).GetType());
}
}
All of the above print "System.RuntimeType". The equivalent code compiled using .NET prints the expected values - System.String, System.Bool, etc.
Has anyone else using Xamarin.Android encountered this? If so, is there a workaround? It is making the use of Reflection impossible for me, and I need it to pass information between JavaScript running in the WebView and the app itself
Aucun commentaire:
Enregistrer un commentaire