Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-14
1
Medium Priority
?
193 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 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