Solved

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

Posted on 2008-10-14
1
185 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
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now