473,509 Members | 2,918 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(code)

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(ms1, ic)

Return (ms.ToArray)

End Function

My Application

Try

Dim s As New ImageWebservice

Dim b As Byte() = s.GetImage("12345")

Dim ms As New MemoryStream(b)

Dim bf As New BinaryFormatter()

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

Dim ms2 As New MemoryStream(ic.myImage)

Dim bt As New Bitmap(ms2) '= DirectCast(Image.FromStream(ms2), Bitmap)

PictureBox1.Image = bt

ms.Close()

b = Nothing

ms = Nothing

Catch ex As Exception

MsgBox(ex.Message)

Finally

End Try

This is the image class.......separate .dll project

Imports System

Imports System.Reflection

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 1543

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

Similar topics

5
3800
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...
3
5461
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...
11
3925
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
1472
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...
0
2059
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...
19
6197
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...
2
5807
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...
4
2238
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...
10
6932
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...
0
7347
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,...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
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...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.