[mono-android] Strange InvalidCastException
uh
u.honermann at windream.com
Fri Nov 18 06:34:05 EST 2011
Hello,
I receive a InvalidCastException, that I cannot understand in the following
codes:
try
{
Android.Runtime.JavaList<Dictionary<String, object>> jl = new
Android.Runtime.JavaList<Dictionary<String, object>>();
Dictionary<String, object> v = new Dictionary<String, object>();
v.Add("szLongName", "Bla.pdf");
jl.Add(v); // Exception
}
catch(Exception ex)
{
}
Exception:
Cannot cast from source type to destination type.
at
Android.Runtime.JavaTypeConverter`1+JavaDictionaryConverter`1[System.Collections.Generic.Dictionary`2[System.String,System.Object],System.Collections.Generic.Dictionary`2[System.String,System.Object]].ToNative
(System.Collections.Generic.Dictionary`2 val) [0x0001c] in
/Users/jon/Development/xamarin/monodroid/Mono.Android/src/Runtime/JavaTypeConverter.cs:298
at
Android.Runtime.JavaList`1[System.Collections.Generic.Dictionary`2[System.String,System.Object]].Add
(System.Collections.Generic.Dictionary`2 item) [0x00000] in
/Users/jon/Development/xamarin/monodroid/Mono.Android/src/Runtime/JavaList.cs:250
at HelloM4A.Activity3.OnCreate (Android.OS.Bundle bundle) [0x00023] in
/Users/uh/Projects/HelloM4A/HelloM4A/Activity3.cs:37
try
{
Android.Runtime.JavaList jl = new Android.Runtime.JavaList();
Dictionary<String, object> v = new Dictionary<String, object>();
v.Add("szLongName", "Bla.pdf");
jl.Add(v);
Dictionary<String, object> vo = (Dictionary<String, object>)jl[0]; //
Exception
}
catch(Exception ex)
{
}
Exception:
Cannot cast from source type to destination type.
at
Android.Runtime.JavaTypeConverter`1+JavaDictionaryConverter`1[System.Collections.Generic.Dictionary`2[System.String,System.Object],System.Collections.Generic.Dictionary`2[System.String,System.Object]].ToNative
(System.Collections.Generic.Dictionary`2 val) [0x0001c] in
/Users/jon/Development/xamarin/monodroid/Mono.Android/src/Runtime/JavaTypeConverter.cs:298
at
Android.Runtime.JavaList`1[System.Collections.Generic.Dictionary`2[System.String,System.Object]].Add
(System.Collections.Generic.Dictionary`2 item) [0x00000] in
/Users/jon/Development/xamarin/monodroid/Mono.Android/src/Runtime/JavaList.cs:250
at HelloM4A.Activity3.OnCreate (Android.OS.Bundle bundle) [0x00023] in
/Users/uh/Projects/HelloM4A/HelloM4A/Activity3.cs:37
I cannot understand, what the problem is. Source and Destination types are
exactly identical.
Regards,
Uwe Honermann
windream GmbH
--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Strange-InvalidCastException-tp5004015p5004015.html
Sent from the Mono for Android mailing list archive at Nabble.com.
More information about the Monodroid
mailing list