473,789 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BinaryFormatter Error assistance

Hi,

I have a webservice returning a serialized class

as

Webservice

Function GetImage(code as string) as Byte()

Dim objBitmap As Bitmap = GetTheImage(cod e)

objBitmap.Save( ms, ImageFormat.Bmp )

Dim ic As New ImageClass

ic.myImage = ms.ToArray

Dim bf As New BinaryFormatter

Dim ms1 As New MemoryStream

bf.Serialize(ms 1, ic)

Return (ms.ToArray)

End Function

My Application

Try

Dim s As New ImageWebservice

Dim b As Byte() = s.GetImage("123 45")

Dim ms As New MemoryStream(b)

Dim bf As New BinaryFormatter ()

Dim ic As ImageClass = DirectCast(bf.D eserialize(ms), ImageClass)

Dim ms2 As New MemoryStream(ic .myImage)

Dim bt As New Bitmap(ms2) '= DirectCast(Imag e.FromStream(ms 2), Bitmap)

PictureBox1.Ima ge = bt

ms.Close()

b = Nothing

ms = Nothing

Catch ex As Exception

MsgBox(ex.Messa ge)

Finally

End Try

This is the image class.......sep arate .dll project

Imports System

Imports System.Reflecti on

Imports System.Drawing

<Serializable() _

Public Class ImageClass

Public myImage As Byte()

Public Sub New()

End Sub

End Class

When I run my application which calls the webservice I get the error

---------------------------
TestHarness
---------------------------
The input stream is not a valid binary format. The starting contents (in
bytes) are: 42-4D-42-3C-00-00-00-00-00-00-36-00-00-00-28-00-00 ...
---------------------------
OK
---------------------------

I am using VB 2005 for both and the webserice is running on the same client
XP SP2.

Any ideas?

Thanks


Jul 26 '07 #1
0 1558

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3835
by: aladdinm1 | last post by:
Hi All, I have an annoying trouble with binary serialization. I have a windows forms application which works like a server and keeps sending data to its clients. The data is serialized before being sent using BinaryFormatter and a serializable object. When using a windows forms application as a client, everything works just fine and deserialized data can be received intact. When the client application is is embedded in Internet Explorer (I...
3
5482
by: Joshua Moore | last post by:
I have a webservice that serializes a ton of variables and other good stuff to a txt file using SoapFormatter (IFormatter), and when I try to deserialize it using the binary formatter, i get the following error: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1986938170.1886350437. I've read a lot about this error from several sources on the net, but can't
11
3959
by: Igor | last post by:
Hi. While executing BinaryFormatter.Deserialize() I get: System.InvalidCastException: Specified cast is not valid. I implemented ISerializable interface. What may be a problem? Thanks.
1
1493
by: pak20116 | last post by:
Hi, all: I've seen numerous questions and answers about this topic on the web, but none of them quite fit to my case. My application is a business process model (like approval process) using ASP.NET. Each transaction, I store related data in the database as a blob. When I retreive the data from database, deserialization fails and I get this error: "BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version...
0
2078
by: Fruber Malcome | last post by:
I'm getting a very weird exception and hoping someone may be able to help. I have an Office Add-In that lives in a .dll (for email reference ai.dll) ai.dll makes calls into the core part of the application implementation in another .dll (let's call that app.dll). app.dll makes a function call into another dll (let's call that one dep.dll). dep.dll has some code in it where it deserializes a memorystream using a binaryformatter.
19
6250
by: Sharon | last post by:
Hi, When I'm doing BinaryFormatter.Deserialize() over a TCP socket. When I'm closing the TcpListener by invoking the TcpListener.Stop(); I get: System.IO.IOException with message "Unable to read data from the transport connection." that InnerException of type System.Net.Sockets.SocketException saying "An established connection was aborted by the software in your host machine".
2
5820
by: Doug Lind | last post by:
Hi all, I have seen a number of posts re: the BinaryFormatter version incompatibility but nothing on how to recover from it. In my case, I want the exception to trigger an alternate behaviour and continue process the stream. My app reads and writes configuration settings to a binary file upon starting and shutdown. The settings are stored in various objects that are serialized and deserialized using a BinaryFormatter. When reading...
4
2250
by: rlrcstr | last post by:
I'm getting an annoying exception: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version XXXX I've looked all over the web and everything that discusses this seems to be associated with web services. Usually indicating that the code is mismatched with BinaryFormatter and SOAPFormatter objects. Stressing that if you use a BinaryFormatter on one side you must use one on the other. Well, I'm only using...
10
6980
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
9506
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6761
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.