D
Dan
All I Am Attempting To Serialize An Object To An XML File.
Here Is The Code For That
public string SaveNewSurvey( MutualSurveyObject
mso_TempObject, int i_JobID )
{
string s_RootFileName;
string s_FinalFileName;
try
{
//Create The Final File Name
s_RootFileName = "job" + i_JobID.ToString() + "config.xml";
s_FinalFileName =
s_SetUpFilePath + @"\" + s_RootFileName;
//Serialize The Object And Write The XML Data
TextWriter tr = new StreamWriter( s_FinalFileName );
XmlSerializer sr = new XmlSerializer( typeof(
MutualSurveyObject ) );
sr.Serialize( tr, mso_TempObject );
tr.Close();
return s_RootFileName;
}
catch ( Exception e )
{
throw e;
}
}
However, When I attempt to execute this I get the
following rather long Exception message
System.Runtime.Serialization.SerializationException: The
type FNIS.MutualSurveyApplication.MutualSurveyObject in
Assembly MutualSurveyStructureObject,
Version=1.0.1411.14253, Culture=neutral,
PublicKeyToken=null is not marked as serializable.
Server stack trace:
at
System.Runtime.Serialization.FormatterServices.InternalGetS
erializableMembers(RuntimeType type, Boolean
excludeNonSerializable)
at
System.Runtime.Serialization.FormatterServices.GetSerializa
bleMembers(Type type, StreamingContext context)
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.InitMemberInfo()
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.InitSerialize(Object obj, ISurrogateSelector
surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter
converter)
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.Serialize(Object obj, ISurrogateSelector
surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter
converter)
at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter
..Serialize(Object graph, Header[] inHeaders,
__BinaryWriter serWriter, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormat
ter.Serialize(Stream serializationStream, Object graph,
Header[] headers, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormat
ter.Serialize(Stream serializationStream, Object graph,
Header[] headers)
at
System.Runtime.Remoting.Channels.CoreChannel.SerializeBinar
yMessage(IMessage msg, Stream outputStream, Boolean
includeVersions)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.
SerializeMessage(IMessage msg, ITransportHeaders& headers,
Stream& stream)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.
SyncProcessMessage(IMessage msg)
The object is complete in terms of being one object that
holds collections of other objects. Is that the problem?
I am lost. Any help would be appreciated.
Dan
Here Is The Code For That
public string SaveNewSurvey( MutualSurveyObject
mso_TempObject, int i_JobID )
{
string s_RootFileName;
string s_FinalFileName;
try
{
//Create The Final File Name
s_RootFileName = "job" + i_JobID.ToString() + "config.xml";
s_FinalFileName =
s_SetUpFilePath + @"\" + s_RootFileName;
//Serialize The Object And Write The XML Data
TextWriter tr = new StreamWriter( s_FinalFileName );
XmlSerializer sr = new XmlSerializer( typeof(
MutualSurveyObject ) );
sr.Serialize( tr, mso_TempObject );
tr.Close();
return s_RootFileName;
}
catch ( Exception e )
{
throw e;
}
}
However, When I attempt to execute this I get the
following rather long Exception message
System.Runtime.Serialization.SerializationException: The
type FNIS.MutualSurveyApplication.MutualSurveyObject in
Assembly MutualSurveyStructureObject,
Version=1.0.1411.14253, Culture=neutral,
PublicKeyToken=null is not marked as serializable.
Server stack trace:
at
System.Runtime.Serialization.FormatterServices.InternalGetS
erializableMembers(RuntimeType type, Boolean
excludeNonSerializable)
at
System.Runtime.Serialization.FormatterServices.GetSerializa
bleMembers(Type type, StreamingContext context)
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.InitMemberInfo()
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.InitSerialize(Object obj, ISurrogateSelector
surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter
converter)
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectI
nfo.Serialize(Object obj, ISurrogateSelector
surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter
converter)
at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter
..Serialize(Object graph, Header[] inHeaders,
__BinaryWriter serWriter, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormat
ter.Serialize(Stream serializationStream, Object graph,
Header[] headers, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormat
ter.Serialize(Stream serializationStream, Object graph,
Header[] headers)
at
System.Runtime.Remoting.Channels.CoreChannel.SerializeBinar
yMessage(IMessage msg, Stream outputStream, Boolean
includeVersions)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.
SerializeMessage(IMessage msg, ITransportHeaders& headers,
Stream& stream)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.
SyncProcessMessage(IMessage msg)
The object is complete in terms of being one object that
holds collections of other objects. Is that the problem?
I am lost. Any help would be appreciated.
Dan