473,473 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Serialize Assembly to Stream and back again

Hi

I am trying to serialize an assembly into a byte array. I am using a
BinaryFormatter to serialize the assembly into a stream. Once in the
stream, would then save this to the database in a byte().

I have come across a few issues with deserializing the stream so I decided
to strip out all the un-necessary code and simply serialize from an assembly
to a stream and then de-serialize is back again using the same
BinaryFormatter.

However, I get the following error:

SaveGUI: Insufficient state to deserialize the object. More information
is needed.

With the following code:

Try
Dim myAssembly As [Assembly]
myAssembly = myAssembly.LoadFile("d:\test.dll")

Dim binFormatter As New Formatters.Binary.BinaryFormatter
Dim stream As New MemoryStream

binFormatter.Serialize(stream, myAssembly)

stream.Position = 0

Dim ass As [Assembly]
ass = binFormatter.Deserialize(stream)

Catch ex As System.Exception
Debug.WriteLine(ex.Message, "SaveGUI")
End Try

Any help on this would be greatly appreciated.

Regards, Carl Gilbert
Jul 21 '05 #1
2 2596
Hi,

why not just use the System.IO classes to read the FileStream of the DLL and
write out the bytes in Base64Encoding to XML. It might be a better option!
Jul 21 '05 #2
The LoadFile is just being used to ensure that a good assembly was being
used. In reality, I will be getting the Assembly at runtime.
The problem is that when I have an Assembly that I know is good, I can not
get back the same assembly after the serialization/de-serialization.
I feel that I am missing something on the serialize settings.

Regards, Carl
"Saurabh Nandu" <Sa**********@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com...
Hi,

why not just use the System.IO classes to read the FileStream of the DLL
and
write out the bytes in Base64Encoding to XML. It might be a better option!

Jul 21 '05 #3

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

Similar topics

5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
5
by: andrewcw | last post by:
I have an object to serialize. TextWriter writer = new StreamWriter("test.xml"); serializer.Serialize(writer,obj); writer.Close(); but below does not, why ?? I have a file that I will have...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
3
by: MAY | last post by:
Hi, I have a problem about serialize the form controls. I wrote a test program to test serialize a from but fail (->An unhandled exception of type...
0
by: Fred Heida | last post by:
Hi Al, i have a funny problem.. i you can call it funny.. what i have is 2 assemblies, the first one does nothing other then Application.Run(new MyForm())
2
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
5
by: objectref | last post by:
Hi to all, let's say i have a form with 2 buttons and 3 textboxes on it. Is there a way to Serialize the form so when i de-Serialize and cast it to a Form, i will get back the original form with...
2
by: Carl Gilbert | last post by:
Hi I am trying to serialize an assembly into a byte array. I am using a BinaryFormatter to serialize the assembly into a stream. Once in the stream, would then save this to the database in a...
1
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
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...
0
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...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.