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
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