using (Stream stream = File.Create("test.xml"))
  {
    DataContractSerializer serializer = new DataContractSerializer(typeof(Ref<MyEntity>));
    serializer.WriteObject(stream, myentityRef);
  }

  using (Stream stream = File.Open("test.xml", FileMode.Open))
  {
    DataContractSerializer serializer = new DataContractSerializer(typeof(Ref<MyEntity>));
    Ref<MyEntity> deserialized = (Ref<MyEntity>)serializer.ReadObject(stream);
  }

This throws an exception :

System.InvalidOperationException was unhandled
  Message=Active Session is required for this operation. Use Session.Open(...) to open it.
  Source=Xtensive.Storage
  StackTrace:
       at Xtensive.Storage.Session.Demand()
       at Xtensive.Storage.Domain.Demand()
       at Xtensive.Storage.Key.Parse(String source)
       at Xtensive.Storage.Ref`1..ctor(SerializationInfo info, StreamingContext context)
       at ReadRefOfMyEntityt3CrkEApFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
       at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
       at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)

asked Oct 15 '10 at 06:21

olorin's gravatar image

olorin
358868792

edited Oct 15 '10 at 06:56

It is not possible to type <t> in title...

(Oct 15 '10 at 06:56) olorin olorin's gravatar image

One Answer:

Will be fixed ASAP.

answered Oct 15 '10 at 08:42

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Fixed; constructors are added as well, + FormattedKey member.

(Oct 15 '10 at 09:34) Alex Yakunin Alex%20Yakunin's gravatar image
(Oct 15 '10 at 09:38) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA