-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to serialize session because SerializationFieldInfo is not marked as serializable #1964
Comments
NHibernate has many session serialization tests, and they do not fail. Can you give more information on how to reproduce this? |
Not yet, but I'll continue to investigate how to reproduce it. Although it is 100% reproduceable on my failing tests, only very few tests are affected for my application too (less than 10% of those that use NHibernate). I assume only very specific entity mappings trigger the bug, so I'll try to find out which ones tomorrow. |
I think I found the problem. Although I don't have a unit test for NHibernate yet or even fully understand it, that's what I found by debugging the .NET Framework serialization code: Objects of the type Some background information:
|
So it's related to entities with lazy properties. And the issue can easily be reproduced on existing test
If LazyTextEntity is modified in the following way (added base class with unmapped property) :
[Serializable]
public class LazyTextEntity : BaseTextEntity
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual string Text { get; set; }
}
[Serializable]
public class BaseTextEntity
{
public virtual int Test { get; set; }
} |
I'm not in front of my code right now, but I'm 99% sure that I don't have any lazy properties. So there has to be another case where these classes are used. |
The following kind of contradicts each other:
|
I have seen this error in regarding to arrays (and particularly arrays of MemberInfo). This is the reason why we have |
I'll check that tomorrow. |
It may also be associations mapped with |
The fields should not change Fixes nhibernate#1964
The fields should not change between serialization and deserialization. Fixes nhibernate#1964
Fix session no more serializable with entities having a field interceptor Fix #1964
I can't update an application from NHibernate 5.1.4 to 5.2.2 (I've also tested 5.2.0). If I update and try to serialize an
ISession
the following exception is thrown in some cases:Since
SerializationFieldInfo
is internal in mscorlib neither my code nor NHibernate can reference it directly. But something must have changed between NHibernate 5.1 and 5.2 that causes anISession
to indirectly contain aSerializationFieldInfo
somewhere.I'm not sure why some sessions cause this issue for me and others don't. I haven't been able to find a specific entity that causes it yet.
My application targets Framework 4.7.1 and I'm currently on the 4.7.2 runtime (Windows 10 1709).
The text was updated successfully, but these errors were encountered: