SerializableType.ToBytes(object obj) throws exception in .net core #2560
Replies: 5 comments
-
It looks like you have some invalid |
Beta Was this translation helpful? Give feedback.
-
It could be a bug... I’ll check. |
Beta Was this translation helpful? Give feedback.
-
It errors because BinaryFormatter does not have a surrogate provider set that we're using to serialize members of System.Reflection namespace (PropertyInfo, etc). But the question is: why is it trying to [de-]serialize property info? And do we want to pre-configure or allow setting the surrogates provider in SerializableType? @billbarosa can you provide an example what is the value of the It seems likely it is a proxy, so you would neet to unproxy it before calling |
Beta Was this translation helpful? Give feedback.
-
@hazzik event is a PreCollectionUpdateEvent, I iterate all entries in the collection, below is an example.
Unproxy the entryAdded does not have any effect. I tried using the Surrogate provider in the Tobytes method and I had no problem. So I will try to fix it. |
Beta Was this translation helpful? Give feedback.
-
If it is a lazy property proxy, it can not be unproxied. A test-case reproducing the issue would help checking what is actually going on. |
Beta Was this translation helpful? Give feedback.
-
I am implementing an Audit Trail Manager in a .net core application. When I call
@event.Collection.NeedsInserting(entryAdded, i, elemType)
, I get aNHibernate.Type.SerializationException
.Investigating this further showed me that the problem is in the
ToBytes()
method, especially when using the BinaryFormatter.StackTrace:
Beta Was this translation helpful? Give feedback.
All reactions