string StrCartNew = Server.UrlDecode(Request.Cookies[CookieName].Value.ToString());
byte[] bt = System.Text.Encoding.Default.GetBytes(StrCartNew);
Stream smNew = new MemoryStream(bt);
IFormatter fmNew = new BinaryFormatter();
ShopCart SCNew = (ShopCart)fmNew.Deserialize(smNew);
foreach(ShopCartItem SCI in SCNew.CartItems)
{
lblResult.Text += "<br/>产品名称:" + SCI.Name;
}
这个我在运行的时候出错。这个错误:
BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.Serialization.SerializationException: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.
这行代码有问题 ShopCart SCNew = (ShopCart)fmNew.Deserialize(smNew);
不知道为什么。
byte[] bt = System.Text.Encoding.Default.GetBytes(StrCartNew);
Stream smNew = new MemoryStream(bt);
IFormatter fmNew = new BinaryFormatter();
ShopCart SCNew = (ShopCart)fmNew.Deserialize(smNew);
foreach(ShopCartItem SCI in SCNew.CartItems)
{
lblResult.Text += "<br/>产品名称:" + SCI.Name;
}
这个我在运行的时候出错。这个错误:
BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.Serialization.SerializationException: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.
这行代码有问题 ShopCart SCNew = (ShopCart)fmNew.Deserialize(smNew);
不知道为什么。
解决方案 »
- 请教 c# winform如何判断窗体已show()相关问题
- 北京哪有培训C#的?
- 使用office的Microsoft Office Document Image Writer虚拟打印机遇到两个问题,请各位打下帮忙
- 高手急救!datagrid取值问题!!!
- 使用FCKeditor插入上传图片,怎么在src前加上自己的域名
- 请问在SQL中如何算出一个时间于这个月的1号之间差几天啊?
- 字符串如何与流相互转换?
- winform窗口关闭,要求得到窗体的返回值-0h或者-1,???
- 关于DataSet更新的问题!
- .NET 按段落读取PDF文档
- Combobox问题
- name=12345,点击确定按钮,如何生成一个保存name信息的xml文件啊?
ShopCart SC = new ShopCart();
SC.AddItem("1", "ProductName", "ProductName", 0, 0, "ProductID", "", 0, 0, 0, 0, "ShopId", "TestUrl", true);
SC.AddItem("2", "ProductName123", "ProductName123", 0, 0, "ProductID123", "", 0, 0, 0, 0, "ShopId111", "TestUrl23", true); //将ShopCart对象写入Cookie
IFormatter fm = new BinaryFormatter();
Stream sm = new MemoryStream();
fm.Serialize(sm, SC);
sm.Seek(0, SeekOrigin.Begin);
StreamReader reader = new StreamReader(sm);
string strCart = reader.ReadToEnd();
reader.Close();
HttpCookie hc = new HttpCookie(CookieName);
hc.Value = Server.UrlEncode(strCart);
hc.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(hc);
BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.Serialization.SerializationException: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 623915045.807743536.