2
反序列化我得到错误:分析完成前遇到的流结束。而在vb.net
End of Stream encountered before parsing was completed while deserializing the file
代码:
Dim fs As FileStream = Nothing
Try
fs = IO.File.OpenRead(Filename)
'fs = New FileStream(Filename, FileMode.Open)
Dim bf As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
bf.AssemblyFormat = Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full
bf.TypeFormat = Runtime.Serialization.Formatters.FormatterTypeStyle.TypesWhenNeeded
fs.Seek(0, SeekOrigin.Begin)
Dim obj As Object = bf.Deserialize(fs)
Return obj
Catch ex As Exception
MsgBox("There was an exception while trying to convert binary file to object. Exception: " & ex.Message & " | Stacktrace: " & ex.StackTrace)
Finally
If fs IsNot Nothing Then
fs.Close()
End If
End Try
我与fs.Position=0
也尝试过,甚至它不工作。
任何人都可以帮助我。在此先感谢
谢谢,你可以请我发布这两个程序的标准代码。我应该使用哪些格式属性? – user2845419
我从来没有使用过它们。 – doker
请发布您的代码序列化,所以我们可以看到。我不再流利地使用vv.net,但是如果你显示你的代码,我们可能会发现一些快速的东西。 – doker