Serialize/deserialize between MONO-client and ASP.NET server - possible or not?

Your big mistake is using BinaryFormatter for this. This has many issues You should trust the data you deserialize. This is rarely the case in client-server applications It uses some internal format, and I'm not sure how compatible that is between different versions of .

Net or even between . Net and mono. Use a serializer with a well defined format Good alternatives for this use-case are Json or Xml serializers.

Personally usually use Json. Net, but . Net has also a built in Json serializier BinaryFormatter might be the right choice if you serialize a complex object graph, don't need versioning and only read it back on the same system, so you can trust the data.

And even in that scenario I'd only use it because I know no better alternative, not because I like BinaryFormatter Since you now stated that you transfer a lot of data I'd look into protobuf-net. It's a binary serializer that is very fast and produces compact data. But you should annotate all your properties with numeric IDs.It's author Marc Gravell is active here on SO, so you can expect good support.

Your big mistake is using BinaryFormatter for this. This has many issues. You should trust the data you deserialize.

This is rarely the case in client-server applications. It uses some internal format, and I'm not sure how compatible that is between different versions of . Net or even between .

Net and mono. Use a serializer with a well defined format. Good alternatives for this use-case are Json or Xml serializers.

Personally usually use Json. Net, but . Net has also a built in Json serializier.

BinaryFormatter might be the right choice if you serialize a complex object graph, don't need versioning and only read it back on the same system, so you can trust the data. And even in that scenario I'd only use it because I know no better alternative, not because I like BinaryFormatter. Since you now stated that you transfer a lot of data I'd look into protobuf-net.It's a binary serializer that is very fast and produces compact data.

But you should annotate all your properties with numeric IDs. It's author Marc Gravell is active here on SO, so you can expect good support.

I do trust the data, as I write both parts, both client and server. But the client uses Mono framework and the data is large amount game data, so using XML would hurt performance quite a bit. The game runs in the client, but all leveldata, prefs, AI etc.Runs on the server, so I need to be able to download data to objects quickly and then put the moves back up to the server.

Not real time. Just efficient. – BerggreenDK Jul 24 at 22:13 Writing the client is not enough.

Controlling the computer it is running on is the issue you don't want a rogue client to be able to hack your server. – CodeInChaos Jul 24 at 22:19 If performance is the issue look into proto-buf.It requires more configuration that most other serializers, but it's very fast and the data is compact. I assumed that you were only transmitting the highscore -- which is usually rather small.

– CodeInChaos Jul 24 at 22:21 regarding cheaters/hackers - yes, I am aware of that part. Thats not my question and I don't think XML nor JSON would do that any different? – BerggreenDK Jul 24 at 22:21 Of course it would be different.

Json/Xml can send you invalid data, but if the deserializer is any good they won't allow the attacker to execute code. Most other serializers go through public properties, require annotations,... BinarySerializer can simply write evil stuff into your private fields, instantiate arbitrary types,... Perhaps it's possible to control it, but I don't know how. – CodeInChaos Jul 24 at 22:26.

BinaryFormatter produces a non-interoperable binary format. Use it only if both the client and the server run the same version of the CLR. Otherwise you could use an interoperable format such as XML (XmlSerializer) or JSON (JavaScriptSerializer) to communicate between your client and server.

I have used Mike Talbot's Silverlight Serializer whydoidoit.com/2010/04/08/silverlight-se... which is very lightweight and should work with both MONO and .NET.

Interesting too, but I stumpled upon this one: "SilverlightSerializer is a binary serializer that works in . NET and Silverlight, allowing you to move your objects between the two instances or store and retrieve them locally in either. " - I need to move between a client and a server, from MONO to NET and back?

– BerggreenDK Jul 25 at 12:39.

Posting my own answer as I actually managed to get it working without extras First of all, thanks for all the great suggestions for extra libraries, but my initial question was about if it was possible to make MONO and ASP. NET communicate through serialization. The answer is: YES!

All I had to to was to build a seperate Class-project (DLL) where I put all the datastructures I need to serialize. Then make it a reference on both platforms and voila, same DLL = same assembly and both platforms agrees that serialization and deserialization is no problem. Note on binary result/traffic/space I agree, the binary data seems to be a bit "overkill" compared to some of the other suggested plugins/libraries in here.

But it IS possible without any extra libs. That was my initial goal.

I have different objects I would like to be able to load and save on a ASP.NET (IIS webserver) from my MONO client. So I have made them as Class objects. As example I have Score which I will be using for producing a hiscore on a server.

This code I want to use as data structure (n-tier architecture) in both MONO as clientside structure and in my ASP.NET server I use it as serverside object too. BUT - on the webserver, in ASP.NET/C# I get an error 500 telling me that it cannot load the assemble for deserializing the data? I've read someone suggesting to make the assemble as external?

And then link it on both platforms, is that possible in my situation or am I on the wrong path somehow? I can easily transfer a simle bytearray with values from 0x00 to 0xff to my ASP.NET and save it. But once I start using serialize/deserialize on my List objects and transfer them into a Byte things messes up?

Is deserialization not possible if the serializer isnt made on the same platform? Is it possible to place the dataobjects (business objects) in a DLL project and then link/use this on both platforms and that way gaining the same assemble value?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions