question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.InvalidCastException while comparing dynamic objects

See original GitHub issue

After 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:closed
  • Created 5 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
GregFinzercommented, Jan 18, 2021

Implemented.

2reactions
GregFinzercommented, Jan 9, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found