序列化/ MONO-客户端和ASP.NET服务器之间的反序列化 - 可能或不? [英] Serialize/deserialize between MONO-client and ASP.NET server - possible or not?

查看:125
本文介绍了序列化/ MONO-客户端和ASP.NET服务器之间的反序列化 - 可能或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从MONO客户不同的对象,我想能够加载和保存在一个ASP.NET(IIS web服务器)。所以我让他们为Class对象。

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.

作为例子,我有[评分]我将使用生产服务器上的hiscore。

As example I have [Score] which I will be using for producing a hiscore on a server.

Score.cs

using System.Runtime.Serialization;
[System.Serializable]
public class Score
{
    public long Total;
    public string Name;
    public Score(){}
    public Score(string name, long total)
    {
        Total = total;
        Name = name;
    }

}

此代码,我要为使用数据结构(n层体系结构),在这两个MONO作为客户方的结构,在我的ASP.NET服务器我用它作为服务器端的对象了。

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.

我做的是我要建立一个列表阵列是这样的:

What I do is that I want to build a list-array like this:

List<Score> hiscores = new List<Score>();
hiscores.add (new Score("Player 1", 10000));
hiscores.add (new Score("Player 2", 20000));
hiscores.add (new Score("Player 3", 30000));
hiscores.add (new Score("Player 4", 40000));



...然后我想它序列转换为bytearray这样我可以发布它作为binaryfile:

... then I want to serialize it into a bytearray so I can POST it as binaryfile:

MemoryStream membytes = new MemoryStream(); 
BinaryFormatter binFormatter = new BinaryFormatter();
binFormatter.Serialize(membytes, hiscores );



...

...

但是 - 上Web服务器,在ASP.NET/C#我得到一个错误500告诉我,它无法加载组装的反序列化数据???

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???

HUH?我读过有人建议,使组装外部?然后链接它在两个平台上,是有可能在我的情况还是我在错误的道路不知何故呢?

HUH?! 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?

我可以很容易地使用值从0x00转移笑着ByteArray的FFH到我的ASP.NET和保存。但是,一旦我开始使用序列化/反序列化我的列表对象,并将它们转移到一个byte []的东西弄乱?

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?


。如果串行心不是在同一个平台上进行反序列化不可能?

QUESTION Is deserialization not possible if the serializer isnt made on the same platform?

有可能放置数据对象(业务对象)在DLL项目,然后链接/使用这两个平台和方式获得相同的组装值吗?

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?

推荐答案

的BinaryFormatter 产生非互操作的二进制格式。仅当客户机和服务器运行的CLR同一版本使用它。否则,你可以使用一个可互操作的格式,如XML( 的XmlSerializer )或JSON(的 的JavaScriptSerializer )客户端和服务器之间进行通信。

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.

这篇关于序列化/ MONO-客户端和ASP.NET服务器之间的反序列化 - 可能或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆