Solved

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

Posted on 2008-10-14
1
190 Views
Last Modified: 2013-11-07
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

0
Comment
Question by:aferia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 22711439
to avoid this situation, you can invoke the deserialization class from outside an instance of your class, maybe form a static (Shared) sub, like:

Public Shared Sub Deserialize(filename as String) as CConnectionData.CSettings

     ... all your stuff here

End Sub
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question