All the examples i've found using XmlSerializer work with one time
serialization / deserialization of objects... or one time
serialization / deserialization of collection of objects.

I need to be able to keep a file stream open, and just serialize
(IrcMessage) objects as they come into my server, then eventually have
some other thread deserialize the accumulated (IrcMessage) objects.
the problem is, every time i call:

                StreamWriter messageWriter = new
StreamWriter(_logFileStream, Encoding.ASCII);
                XmlSerializer writer = new
XmlSerializer(typeof(IrcMessage));
                writer.Serialize(messageWriter, ircMessage2);

where:

    [Serializable]
    public class IrcMessage
    {
        int _channelId = -1;
        public int ChannelId
        {
            get { return _channelId; }
            set { _channelId = value; }
        }

        string _ircMessageText = null;
        public string IrcMessageText
        {
            get { return _ircMessageText; }
            set { _ircMessageText = value; }
        }
   }

it causes the following output:

<?xml version="1.0" encoding="us-ascii"?>
<IrcMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <ChannelId>1</ChannelId>
  <IrcMessageText>103 Host my hostabc</
IrcMessageText>
</IrcMessage><?xml version="1.0" encoding="us-ascii"?>
<IrcMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <ChannelId>2</ChannelId>
  <IrcMessageText>boohaha string</IrcMessageText>
</IrcMessage><?xml version="1.0" encoding="us-ascii"?>
<IrcMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <ChannelId>1</ChannelId>
  <IrcMessageText>sasdjlfsdjfsdjsfdjkfsdjksdfjksdafjk;sd;jasdf</
IrcMessageText>
</IrcMessage>

one problem is i don't want the xml version info to keep being
rewritten...

when trying to deserialize:

            StreamReader ircMessageReader = new
StreamReader(logFileStream);
            XmlSerializer ircMessageParser = new
XmlSerializer(typeof(IrcMessage));
            return
(IrcMessage)ircMessageParser.Deserialize(ircMessageReader);

i blow up with Unexpected XML declaration... trying to manually remove
the declaration from the files causes other errors.  but this is only
1 issue i'm seeing.

i could accumulate the objects in a collection then do a onetime
serialization of a collection of IrcMessage objects, then deserialize
the collection in the same manner - but this IS NOT what i'm after.
I.e. i wish to serialize IrcMessage objects to file as they come
in...  (as stated in 2nd paragraph)

any help would be most appreciated!

thanks, dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

Reply via email to