NameValueCollection可否二进制序列化

rachy 2005-02-04 04:57:13
问题情况:使用remoting,当向服务器端传递NameValueCollection类型参数时,出错。
询问:NameValueCollection可否二进制序列化?
...全文
163 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
rachy 2005-02-04
  • 打赏
  • 举报
回复
这样倒是可以二进制序列化,但为什么remoting服务器端使用传入的NameValueCollection参数时会出错呢,不使用该参数是正确的,NameValueCollection传递的只是查询条件而已,没有做remoting之前是完全正确的
henryfan1 2005-02-04
  • 打赏
  • 举报
回复
/// <summary>
/// 把对象序列化并返回相应的字节
/// </summary>
/// <param name="pObj">需要序列化的对象</param>
/// <returns>byte[]</returns>
public byte[] SerializeObject(object pObj)
{
if(pObj == null)
return null;
System.IO.MemoryStream _memory = new System.IO.MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(_memory,pObj);
_memory.Position = 0;
byte[] read = new byte[_memory.Length];
_memory.Read(read,0,read.Length);
_memory.Close();
return read;


}
试下就知道
The123 2005-02-04
  • 打赏
  • 举报
回复
System.Runtime.Remoting.Channels.BinaryClientFormatterSink
rachy 2005-02-04
  • 打赏
  • 举报
回复
那种太简单了,现在知道实现的方法,只是看NameValueCollection可否二进制序列化?
如果不能就不能用它作为参数
rachy 2005-02-04
  • 打赏
  • 举报
回复
NameValueCollection 类型不可以xml序列化,这点可以肯定
但不知道能不能二进制序列化,
有没有肯定点的答案啊……或者提供点资料给小弟看看
amendajing 2005-02-04
  • 打赏
  • 举报
回复
我用过这个,不过是简单的,我是看msdn帮助的,你也看看,或许有帮助!
The123 2005-02-04
  • 打赏
  • 举报
回复
应该是可以的。

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧