I am trying to deserialize a custom object that has been previously serialized and saved in a file. and I have the following code:
PHP Code:
        If open.ShowDialog Windows.Forms.DialogResult.OK Then
            Dim fs 
As FileStream = New FileStream(open.FileNameFileMode.Open)
            Try
                
testing = New ItemInfo
                Dim formatter 
As New BinaryFormatter
                Dim obj 
As Object formatter.Deserialize(fs)
                
testing DirectCast(objItemInfo)
            Catch 
ex As Exception
                MsgBox
(ex.Message)
            Finally
                
fs.Close()
            
End Try
        
End If 
The problem is the line
PHP Code:
testing DirectCast(objItemInfo
I am getting an exception:
Object not set to an instance of an object
I have verified that the variable testing and obj are actually instantiated. That leaves ItemInfo which is the name of my custom type (Not an instance of the class).

Since the variable testing and obj are instantiated it seems like it does not like the reference to the class ItemInfo.
What could I be doing wrong here?