Link to home
Start Free TrialLog in
Avatar of aferia
aferia

asked on

How can I assign "Me" reference from a class to a value?

I am trying to write a LoadFromFile() Sub that will deserialize a file from the HD into my class object, but I cant do it because " 'Me' cannot be target of an assignment ". Right now I am deserializing into a temporary object and then assigning member by memebr to the Me instance. Is thera a way around this?
Dim formatter As System.Runtime.Serialization.Formatters.Binary.BinaryFormatter = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
        Dim output As FileStream
        Dim fileName As String = file.FullName
 
        Try
            output = New FileStream(fileName, FileMode.Open, FileAccess.Read)
            Dim tempCon As CConnectionData.CSettings
            tempCon = formatter.Deserialize(output)
            Me.m_szDatabase = tempCon.m_szDatabase
            Me.m_szLoginName = tempCon.m_szLoginName
            Me.m_szPassword = tempCon.m_szPassword
            Me.m_szSQLServer = tempCon.m_szSQLServer
            Me.m_nAuthenticationType = tempCon.m_nAuthenticationType
            output.Flush()
            output.Close()
        Catch ex As System.Runtime.Serialization.SerializationException
            Console.WriteLine("Error Reading from File. " & ex.Message)
        End Try

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial