System.ArgumentException: Conversion buffer overflow.
at System.Text.UTF8Encoding.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byt
eCount, Char[] chars, Int32 charIndex, UTF8Decoder decoder)
at System.Text.UTF8Decoder.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byte
Count, Char[] chars, Int32 charIndex)
at System.IO.BinaryReader.InternalReadOneChar()
at System.IO.BinaryReader.Read()
at System.IO.BinaryReader.PeekChar()高手指教……不知与以下代码有没关系?
public static byte[] Serialize(object obj)
{
try
{
BinaryFormatter binaryF = new BinaryFormatter();
MemoryStream ms = new MemoryStream(1024*10);
binaryF.Serialize(ms, obj);
ms.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[(int)ms.Length];
ms.Read(buffer, 0, buffer.Length);
ms.Close();
return buffer;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
at System.Text.UTF8Encoding.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byt
eCount, Char[] chars, Int32 charIndex, UTF8Decoder decoder)
at System.Text.UTF8Decoder.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byte
Count, Char[] chars, Int32 charIndex)
at System.IO.BinaryReader.InternalReadOneChar()
at System.IO.BinaryReader.Read()
at System.IO.BinaryReader.PeekChar()高手指教……不知与以下代码有没关系?
public static byte[] Serialize(object obj)
{
try
{
BinaryFormatter binaryF = new BinaryFormatter();
MemoryStream ms = new MemoryStream(1024*10);
binaryF.Serialize(ms, obj);
ms.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[(int)ms.Length];
ms.Read(buffer, 0, buffer.Length);
ms.Close();
return buffer;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货