Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BinaryFormatter Version incompatibility

Status
Not open for further replies.

protechdm

Programmer
Dec 30, 2001
36
GB
Hi,

Getting the error message:-

Additional information: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 335546368.-16770048.

From the code below, in the PictureFormat method - which is the delegate for the Format property of the image - the error occurs when the memory stream is deserialized. The graphic is stored in an Access database as a bitmap.

I've read various articles about how this error message arises but none seem applicable. I even tried converting a string to bytes and deserializing, this worked fine.

Many thanks,

Glyn.

Private Sub Test_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oAccess As Access = New Access()
Dim dtTable As DataTable
dtTable = oAccess.ExecSPReturnDT("images", "select * from images")

Dim bdPhoto As Binding
bdPhoto = New Binding("Image", dtTable, "image")
AddHandler bdPhoto.Format, AddressOf PictureFormat

Photo.DataBindings.Add(bdPhoto)
txtID.DataBindings.Add(New Binding("Text", dtTable, "imageid"))
'RunReport("stndbord")
End Sub

Private Sub PictureFormat(ByVal sender As Object, ByVal e As ConvertEventArgs)
Dim img As Image = Nothing
Dim membytes As Byte() = e.Value

Dim ms As MemoryStream = New MemoryStream(membytes)
Dim formatter = New BinaryFormatter()
****THIS NEXT LINE THROWS THE ERROR
img = CType(formatter.deserialize(ms), Image)

Dim bmp As Bitmap = New Bitmap(img)
ms.Close()

e.Value = img
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top