[Android] Firestore: System.ArgumentException: Object of type 'System.Double' cannot be converted to type 'System.Single'
See original GitHub issueHi @TobiasBuchholz, I am currently testing your library on my Android app, and there’s actually an error when reading an existing document from the DataBase using : documentSnapshot.Data
IDocumentSnapshot<T> documentSnapshot = await documentReference.GetDocumentSnapshotAsync<T>();
if (documentSnapshot?.Data != null) // <---- System.ArgumentException occuring here
{
return documentSnapshot.Data;
}
else
{
throw new Exception("DOCUMENT NOT FOUND");
}
StackTrace
System.ArgumentException: Object of type 'System.Double' cannot be converted to type 'System.Single'.
at System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00056] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/RuntimeType.cs:201
at System.Reflection.RuntimeMethodInfo.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00069] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:454
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00040] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:385
at System.Reflection.RuntimePropertyInfo.SetValue (System.Object obj, System.Object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x0005d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimePropertyInfo.cs:469
at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/PropertyInfo.cs:57
at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/PropertyInfo.cs:54
at Plugin.Firebase.Android.Extensions.JavaObjectExtensions.Cast (System.Collections.IDictionary this, System.Type targetType, System.String documentId) [0x000b4] in <becdb5103fb14132a70e7e52fa7d7747>:0
at Plugin.Firebase.Android.Extensions.JavaObjectExtensions.Cast[T] (System.Collections.Generic.IDictionary`2[TKey,TValue] this, System.String documentId) [0x00000] in <becdb5103fb14132a70e7e52fa7d7747>:0
at Plugin.Firebase.Android.Firestore.DocumentSnapshotWrapper`1[T].get_Data () [0x00023] in <becdb5103fb14132a70e7e52fa7d7747>:0
Setup
Visual Studio Community 2022 for Mac (17.0.7) Xamarin.Android (12.3.3.3) Xamarin.Forms (5.0.0.2012) Plugin.Firebase V1.1.2
Context
I guess it’s the IDocumentReference field that is causing the issue. Indeed, no issue is raised after removing the properties of type IDocumentReference from my document model. Could you please have a look ? Thanks in advance for your help 🙏
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Object of type 'System.Double' cannot be converted to ...
Your input dataRow[aField.Name] is of type System. Double while the field you want to assign to is of type System. Int32 .
Read more >[Solved] Unable to cast object of type 'system.double' ...
Solution 1 Confusingly, the float data type in SQL maps to the double type in C#. You'll need to modify your C# property...
Read more >Firestore: Couldn't put object of type System.Collections. ...
Issue: The firetore feature shows an error when when uploading a 'firestore-Map' ( a dictionary in the c# world) into the firestore database....
Read more >C# – Object of type 'System.Double' cannot be converted to ...
I am facing problem in my code, its telling system.int32 cant not be converted to system.double , here is my code. I have...
Read more >Firebase Apple SDK Release Notes - Google
Fixed implicit type conversion of integer or numeric string parameters to double when modifying or creating events from the Google Analytics interface.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the pinpointing @Kapusch! I’ve created a fix and committed it to the development branch.
Hi @Kapusch, is it possible for you to show some code, e.g. the class that is the snapshots data type? It would also be interesting to see how this object is represented in the firestore database at the firebase console, could you mabe take a screenshot?