【发布时间】:2019-09-01 16:05:33
【问题描述】:
我想将我的类实例变量转换为 byte[] ,然后将其传递给 Web 服务。
在我的网络服务中,我尝试将其转换回类 -
服务器收到此错误:
System.Runtime.Serialization.SerializationException: '无法找到程序集 'App_Web_xrrt4fej, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'。'
// client code:
[Serializable]
public class result
{
public string message { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
byte[] b = ObjectToByteArray(new result() { message = "ok" });
string ss = serv.HelloWorld34(b);
}
// server code:
[Serializable]
public class result
{
public string message { get; set; }
}
[WebMethod]
public string HelloWorld34(byte[] arrBytes)
{
MemoryStream memStream = new MemoryStream();
BinaryFormatter binForm = new BinaryFormatter();
memStream.Write(arrBytes, 0, arrBytes.Length);
memStream.Seek(0, SeekOrigin.Begin);
// the line that has error
result obj = (result)binForm.Deserialize(memStream);
return "1";
}
【问题讨论】:
标签: c# asp.net web-services