Click here to Skip to main content
15,920,801 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCommand prompt (cmd.exe) as a hidden process Pin
Martin.Smith18-Dec-06 2:58
Martin.Smith18-Dec-06 2:58 
AnswerRe: Command prompt (cmd.exe) as a hidden process Pin
Dave Kreskowiak18-Dec-06 8:42
mveDave Kreskowiak18-Dec-06 8:42 
GeneralRe: Command prompt (cmd.exe) as a hidden process Pin
Martin.Smith18-Dec-06 23:06
Martin.Smith18-Dec-06 23:06 
QuestionFile transfer on LAN.......... Pin
Nagraj Naik18-Dec-06 1:59
Nagraj Naik18-Dec-06 1:59 
AnswerRe: File transfer on LAN.......... Pin
Dave Kreskowiak18-Dec-06 6:00
mveDave Kreskowiak18-Dec-06 6:00 
GeneralRe: File transfer on LAN.......... Pin
Nagraj Naik18-Dec-06 19:21
Nagraj Naik18-Dec-06 19:21 
GeneralRe: File transfer on LAN.......... Pin
Dave Kreskowiak19-Dec-06 3:12
mveDave Kreskowiak19-Dec-06 3:12 
QuestionDeserialization Pin
Nick Jones18-Dec-06 0:30
Nick Jones18-Dec-06 0:30 
I am trying to deserialize data into a class with a different name from that which was serialized. I believe the solution should be simple with a SerializationBinder but this doesn't seem to work if the class contains an enumerated member.

The simplified example below throws ArgumentException: "Object of type 'SerializationTest.NewClassToDeserialize' cannot be converted to type 'SerializationTest.OldClassToSerialize+eBar'."

-------------------
Module TestModule

Sub Main()
Dim tOldObject As New OldClassToSerialize
tOldObject.Foo = "My Data Value"

' Serialize object in old format
Dim tFilePath As String = Path.GetTempFileName()
Dim tBinaryWriteStrm As FileStream = File.Create(tFilePath)
Dim tBinaryWriteFomatter As New BinaryFormatter()
tBinaryWriteFomatter.Serialize(tBinaryWriteStrm, tOldObject)
tBinaryWriteStrm.Close()

' Deserialize object in new format
Dim tBinaryReadStrm As FileStream = File.OpenRead(tFilePath)
Dim tBinaryReadFomatter As New BinaryFormatter()

' Override binding to bind to NewClassToDerialize
tBinaryReadFomatter.Binder = New MyBinder

' Enum leads to ArgumentException
Dim tNewUntypedObject As Object = tBinaryReadFomatter.Deserialize(tBinaryReadStrm)
tBinaryReadStrm.Close()

Console.WriteLine(tNewUntypedObject.ToString)
Console.ReadLine()
End Sub

End Module


<Serializable()> Public Class OldClassToSerialize
Public Enum eBar
EnumVal1
EnumVal2
End Enum

Public Foo As String
Public Bar As eBar
End Class

<Serializable()> Public Class NewClassToDeserialize
Public Foo As String
Public Bar As OldClassToSerialize.eBar
End Class

Public Class MyBinder
Inherits SerializationBinder

Public Overrides Function BindToType(ByVal assemblyName As String, ByVal typeName As String) As System.Type
Return GetType(NewClassToDeserialize)
End Function
End Class
--------------------

It works fine if you comment out the member 'Bar'! Can anyone tell me how to handle the enum?

Many thanks,
Nick
QuestionHow i read/write data from the USB port in vb.net? Pin
Agbaria Ahmad17-Dec-06 20:51
Agbaria Ahmad17-Dec-06 20:51 
AnswerRe: How i read/write data from the USB port in vb.net? Pin
Dave Kreskowiak18-Dec-06 5:53
mveDave Kreskowiak18-Dec-06 5:53 
QuestionFormatting dates in a crystal report Pin
steve_rm17-Dec-06 18:06
steve_rm17-Dec-06 18:06 
AnswerRe: Formatting dates in a crystal report Pin
Tarakeshwar Reddy17-Dec-06 19:27
professionalTarakeshwar Reddy17-Dec-06 19:27 
QuestionHow to programatically select a windows media player playlist Pin
ckase17-Dec-06 17:22
ckase17-Dec-06 17:22 
QuestionCapture the tab key on the key down Pin
steve_rm17-Dec-06 16:31
steve_rm17-Dec-06 16:31 
AnswerRe: Capture the tab key on the key down Pin
Tarakeshwar Reddy17-Dec-06 17:54
professionalTarakeshwar Reddy17-Dec-06 17:54 
AnswerRe: Capture the tab key on the key down Pin
The ANZAC17-Dec-06 18:36
The ANZAC17-Dec-06 18:36 
QuestionSimple printing from a text file Pin
rudemusik17-Dec-06 12:14
rudemusik17-Dec-06 12:14 
AnswerRe: Simple printing from a text file Pin
Agus Budianto27-Dec-06 3:21
Agus Budianto27-Dec-06 3:21 
QuestionGraphic File Viewer Pin
Simmy717-Dec-06 9:23
Simmy717-Dec-06 9:23 
AnswerRe: Graphic File Viewer Pin
Dave Kreskowiak17-Dec-06 10:27
mveDave Kreskowiak17-Dec-06 10:27 
QuestionComponent Analysing Pin
Mark0617-Dec-06 9:17
Mark0617-Dec-06 9:17 
AnswerRe: Component Analysing Pin
Dave Kreskowiak17-Dec-06 10:29
mveDave Kreskowiak17-Dec-06 10:29 
AnswerRe: Component Analysing Pin
Jason McBurney18-Dec-06 11:49
Jason McBurney18-Dec-06 11:49 
GeneralSource Code For Advanced HTML Editor Pin
Nagarjun Bodduna17-Dec-06 5:45
Nagarjun Bodduna17-Dec-06 5:45 
GeneralRe: Source Code For Advanced HTML Editor Pin
S Douglas19-Dec-06 1:05
professionalS Douglas19-Dec-06 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.