Lazy property throwing casting exception

Description

Lazy property throws casting exception "Unable to cast object of type 'System.Object' to type 'System.Byte[]"
if object is beeing created and refreshed within the same session:

[Test]
public void Can_LazyPropertyCastingException()
{
//following causes exception "Unable to cast object of type 'System.Object' to type 'System.Byte[]'.
//notice that ClassA.Blob_Field s declared as lazy property
//PS. Exception is beeing thrown only if object was created within the same session

using (ISession session = this.OpenSession()) {
ClassA classA;

#region create and save new entity
classA = new ClassA();
classA.Text = "new entity";
classA.Blob_Field = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
using (ITransaction trans = session.BeginTransaction()) {
session.Save(classA);
trans.Commit();
}
#endregion

session.Refresh(classA);

classA.Text = "updated entity";
using (ITransaction trans = session.BeginTransaction()) {
session.SaveOrUpdate(classA);
trans.Commit();
}

session.Refresh(classA);
}
}

Check attached test.

Similar to fixed https://nhibernate.jira.com/browse/NH-2510#icft=NH-2510
https://nhibernate.jira.com/browse/NH-2510

Environment

None

Attachments

1

Activity

Show:

Alex Zaytsev 
September 8, 2014 at 11:31 AM

Close issues resolved in 3.3.3

Alex Zaytsev 
January 17, 2013 at 7:49 AM

Fixed in 3.3.x cf26aa3e7dfb00b55e8c6a8b14c341d637bba404

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created August 30, 2011 at 5:15 AM
Updated September 8, 2014 at 11:31 AM
Resolved January 17, 2013 at 7:47 AM
Who's Looking?