System.InvalidCastException while comparing dynamic objects
See original GitHub issueAfter upgrading CompareNETObjects package some dynamic object related tests stopped to working.
Exception:
Message: System.InvalidCastException : Unable to cast object of type 'S.S.Data.Delta`1[S.S.Core.Tests.Data.DeltaNestedTests+First]' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
Callstack:
at KellermanSoftware.CompareNetObjects.TypeComparers.PropertyComparer.HandleDynamicObject(Object objectValue, Type objectType)
at KellermanSoftware.CompareNetObjects.TypeComparers.PropertyComparer.GetCurrentProperties(CompareParms parms, Object objectValue, Type objectType)
at KellermanSoftware.CompareNetObjects.TypeComparers.PropertyComparer.PerformCompareProperties(CompareParms parms, Boolean ignoreBaseList)
at KellermanSoftware.CompareNetObjects.TypeComparers.ClassComparer.CompareType(CompareParms parms)
at KellermanSoftware.CompareNetObjects.RootComparer.Compare(CompareParms parms)
at KellermanSoftware.CompareNetObjects.CompareLogic.Compare(Object object1, Object object2)
Some previous version did work, but cannot say for sure what version was that.
The objects being compared are equal from what I can tell.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
c# - How to fix InvalidCastException for dynamic object?
This code generates InvalidCastException: Unable to cast object of type 'SOMELIB.Graphics' to type 'SOMELIB.Object'. When the comparison occurs:.
Read more >ExpandoObject Class (System.Dynamic)
Represents an object whose members can be dynamically added and removed at run time.
Read more >InvalidCastException Class (System)
An InvalidCastException exception is thrown when the conversion of an instance of one type to another type is not supported. For example, attempting...
Read more >The 10 Most Common Mistakes in C# Programming
Don't fall into one of these C# programming mistakes that even savvy developers can find problematic. Read on to see all 10.
Read more >Using Objects Comparer To Compare Complex Objects In C#
Now, Objects Comparer supports enumerables (arrays, collections, lists), multidimensional arrays, enumerations, flags, and dynamic objects ( ...
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 Free
Top 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

Implemented.
Just to give everyone an update that is hoping to get this feature. This is a major change. I am swamped with overtime on my day job and the normal weeknight and weekend hours for my side business Kellerman Software. It will be a while before I can create this feature.