You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by Nicko Cadell <ni...@neoworks.com> on 2005/07/05 18:01:04 UTC

RE: LoggingEvent implements Iserializable, yet isn't serializable

This is a confusion due to Microsoft overloading the term Serializable.
There are 2 kinds of serialisation in .NET:

The first is Remoting Serialization, this is the traditional form
serialization where a graph of objects is persisted to some form of
external representation. Types that support this type of serialisation
are identified by the SerializableAttribute and optionally by the
ISerializable interface. The remoting infrastructure can persist the
object graphs in various ways including a binary representation and an
XML format (which is not suitable for web services).

The other form of serialization is XML Serialisation. This is completely
different as it uses simple reflection to capture and restore the values
of an object's properties. While this is a very convenient mechanism for
converting between XML infoset representations and in memory objects I
do wish that Microsoft had called it something else. The ISerializable
has nothing to do with XML Serialisation.

The LoggingEvent object is not designed to support XML Serialisation
only Remoting Serialization.

If you need to pass data to a Webservice you will need to create your
own simple object which supports XML Serialisation and then populate
this from the LoggingEvent.

Cheers,

Nicko

> -----Original Message-----
> From: Jesse Weigert [mailto:jweigert@azaleos.net] 
> Sent: 30 June 2005 18:48
> To: log4net-dev@logging.apache.org
> Subject: LoggingEvent implements Iserializable, yet isn't serializable
> 
> I was trying to implement an appender which will send the 
> LoggingEvent to a webservice, but I can't get this to work 
> because LoggingEvent is not really serializable.  When I make 
> a webmethod which accepts a loggingEvent as a parameter, I 
> receive this message:
> 
> [InvalidOperationException: log4net.Core.LoggingEvent cannot 
> be serialized because it does not have a default public constructor.]
>    System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, 
> MemberInfo source, Boolean directReference) +178
>  
> System.Xml.Serialization.XmlReflectionImporter.ImportMemberMap
> ping(XmlRe
> flectionMember xmlReflectionMember, String ns, XmlReflectionMember[]
> xmlReflectionMembers) +34
>  
> System.Xml.Serialization.XmlReflectionImporter.ImportMembersMa
> pping(XmlR
> eflectionMember[] xmlReflectionMembers, String ns, Boolean
> hasWrapperElement) +300
> 
> Was LoggingEvent supposed to be serializable?
> 
> -Jesse
>