I have a class containing string variables, hashtables..I managed to
serialize it into a memory stream instead of file stream. Would like to know
how can I convert the byte array to string. I tried using
encoding.default.getstring but the output is an empty string..(:..damn!
partial code example that copied for microsoft for testing purpose:
Dim addresses As New Hashtable
addresses.Add("Jeff", "123 Main Street, Redmond, WA 98052")
addresses.Add("Fred", "987 Pine Road, Phila., PA 19116")
addresses.Add("Mary", "PO Box 112233, Palo Alto, CA 94301")
Dim mstrm As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(mstrm, addresses)
dim str as string = encoding.default.getstring(mstrm.toarray)
Please advise. 6 2487
Red Devil,
The nices one I know
\\\ from a message from Tom Shelton
Private Function SerializeFontObject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(mem, fnt)
Return Convert.ToBase64String(mem.ToArray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Convert.FromBase64String(fnt))
Try
Return DirectCast(bf.Deserialize(mem), Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function
///
I hope this helps a little bit?
Cor
Cor,
Awesome...juz what I'm looking for...
thanx a lot..appreciate that.
"Cor Ligthert" wrote: Red Devil,
The nices one I know
\\\ from a message from Tom Shelton Private Function SerializeFontObject(ByVal fnt As Font) As String Dim bf As New BinaryFormatter Dim mem As New MemoryStream Try bf.Serialize(mem, fnt) Return Convert.ToBase64String(mem.ToArray()) Catch Return String.Empty Finally mem.Close() End Try End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font Dim bf As New BinaryFormatter Dim mem As New MemoryStream(Convert.FromBase64String(fnt)) Try Return DirectCast(bf.Deserialize(mem), Font) Finally If Not mem Is Nothing Then mem.Close() End If End Try End Function ///
I hope this helps a little bit?
Cor
Cor,
Another problem occurred. It doesn't happen all time thou. I did a load test
using load runner. On an occassion, the serialized string is incomplete.
Encounter such problem before?
The data is sent from client to server via socket.
"Cor Ligthert" wrote: Red Devil,
The nices one I know
\\\ from a message from Tom Shelton Private Function SerializeFontObject(ByVal fnt As Font) As String Dim bf As New BinaryFormatter Dim mem As New MemoryStream Try bf.Serialize(mem, fnt) Return Convert.ToBase64String(mem.ToArray()) Catch Return String.Empty Finally mem.Close() End Try End Function
Private Function DeserializeFontObject(ByVal fnt As String) As Font Dim bf As New BinaryFormatter Dim mem As New MemoryStream(Convert.FromBase64String(fnt)) Try Return DirectCast(bf.Deserialize(mem), Font) Finally If Not mem Is Nothing Then mem.Close() End If End Try End Function ///
I hope this helps a little bit?
Cor
Red Devil,
That is the part I don't like.
However set a message in the newsgroup
microsoft.public.dotnet.languages.vb
There this probem is often handled. Although you can have the same results
here.
So crossposting to both newsgroups with your problem.(one message to both in
one time) will probably give you the best results.
Cor
Cor,
What do you mean by 'That is the part I don't like.'?
"Cor Ligthert" wrote: Red Devil,
That is the part I don't like.
However set a message in the newsgroup
microsoft.public.dotnet.languages.vb
There this probem is often handled. Although you can have the same results here.
So crossposting to both newsgroups with your problem.(one message to both in one time) will probably give you the best results.
Cor
Red Devil, The data is sent from client to server via socket.
I don't like it being busy in that area, I never did, that is all.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Red Devil |
last post by:
I have a class containing string variables, hashtables..I managed to
serialize it into a memory stream instead of file stream. Would like to know
how can I convert the byte array to string. I tried...
|
by: andrew lowe |
last post by:
Hi,
Please bear with me on this problem, first I'll give you some background:
I have an object that contains a DateTime field which i pass to a webservice
public class Foo {
public DateTime...
|
by: Gator |
last post by:
Hi All,
Basically my situation is this, I have a server implemented in C++,
unmanaged code, using proprietery protocol over TCP/IP to communicate
with the cilent(c++ also).
Now, I am implementing...
|
by: John Grandy |
last post by:
make a call to XML Web Service WebMethod ... returns object myArray with
no error ...
myArray contains objects of type StringKeyStringValue
runtime error occurs on accessing properties of...
|
by: Pierre |
last post by:
Hi,
I'm trying to select specific nodes from a XmlDocument filled with a
serialized object and to insert these nodes into another XmlDocument.
The object is well serialized (see below). From a...
|
by: EqDev |
last post by:
I have a class that is a control derived from UserControl. I want to use
serialization and deserialization with this calss but I get an exception
"Cannot serialize member...
|
by: madani |
last post by:
Hi,
I need to get serialized string of Page ViewState in Constructor of my
custom web control.
I can not override SavePageStateToPersistenceMedium Method of page
object because I'm in different...
|
by: MMiGG |
last post by:
Hi
Our project need parse JAVA serialized object string in C, has any library?
Thanx
|
by: Buddy Home |
last post by:
Hello,
I'm trying to speed up a piece of code that is causing performance issues
with our product. The problem is we are using serialization to convert the
object to a string, this is costing us...
|
by: sklett |
last post by:
I wasn't sure how to phrase the subject.
Currently I'm storing a file as a byte in a database, when I want to work
with the file I download the byte and write the data to a file on disk
then...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
| |