[Mono-list] Problem with XML-Serialization

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Mon Jul 13 03:57:56 EDT 2009


Hi,

Your subject implies it is about xml serialization, but it is
marked as [Serializable]. Which "serialization" do you mean?
XML serialization, or remoting SOAP serialization?

Atsushi Eno


Blackskyliner wrote:
> Hi I just jumped in into mono I hope I'm in the right forum/mailinglist,
> because i wrote an little server application that I wanted to run on my
> linux machine. Its originally written in .NET 2.0
> 
> To exchange Messages between Server and Client I use an XML-serialized
> class....
> In .NET I dont get any problems but with mono I get the following exception:
> 
>  There was an error generating the XML document. > The type of the argument
> object 'ChatClient.serverMessages' is not primitive.
> 
> I implemented the serverMessage in the following way:
> 
> using System;
> using System.Text;
> 
> namespace ChatClient
> {
>     [Serializable]
>     public class Message
>     {
>         public Message_StatusCodes statusCode;
>         public messageType messageType;
>         public object message;
>         public DateTime time;
>         public string user;
> 
>         public Message()
>         {
>             init();
>         }
> 
>         public Message(string Username)
>         {
>             init();
>             this.user = Username;
>         }
> 
>         private void init(){
>             this.statusCode = Message_StatusCodes.NULL;
>             this.message = null;
>             this.time = DateTime.Now;
>             this.user = null;
>             this.messageType = messageType.NULL;
>         }
> 
>         public void Clear()
>         {
>             this.statusCode = Message_StatusCodes.NULL;
>             this.messageType = messageType.NULL;
>             this.message = null;
>             this.time = DateTime.Now;
>             this.user = null;
>         }
> 
>         public void Clear(string Username)
>         {
>             this.Clear();
>             this.user = Username;
>         }
> 
>         public Message(Message_StatusCodes c)
>         {
>             init();
>             this.statusCode = c;
>         }
>     }
> 
>     public enum Message_StatusCodes
>     {
>         NULL,
> 
>         Login,
> 
>         UserKicked,
>         UserJoined,
>         UserConnected,
>         UserDisconnected,
> 
>         UserListChanged
>     }
> 
>     public enum messageType{
>         NULL,
>         UserMessage,
>         ServerMessage,
>         ClientMessage
>     }
> 
>     public enum serverMessages
>     {
>         LOGIN_ERROR_UserAlreadyExist,
>         LOGIN_ERROR_UsernameReserved,
>         LOGIN_OK
>     }
> 
>     public enum clientMessages
>     {
>         Disconnect
>     }
> }
> 
> 
> Why does this not deserialize in Mono but in C#?? Is there any workaround or
> smth. else?
> 
> I'm thankful about every answer...
> Blackskyliner



More information about the Mono-list mailing list