I have a module which retrieve a serialized nhibernate object from the dragged object :
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
Object content = XamlServices.Load((new StringReader(dragObject.Xaml)));
But I get an exception in the second line saying :
failed to lazily initialize a collection, no session or session was closed
I assume your
dragObjectis the object which is serialized with nhibernate. Apparently theXamlproperty is lazy loaded (or accesses a lazy loaded property of the class).You need to load the
dragObjectin the same session where you access all lazy loaded properties:Alternatively you can also eager load the lazy properties.