Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More on cloning
Message
From
16/04/2013 15:40:09
 
 
To
16/04/2013 15:30:17
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01571111
Message ID:
01571130
Views:
39
>How are you handling the cloning process? If you are doing a shallow copy, then properties in both the original and cloned objects may refer to the same object. See http://msdn.microsoft.com/en-us/library/system.object.memberwiseclone%28v=vs.90%29.aspx.

MemberwiseClone() is executing a shallow copy.

From my main App class, it is like this:
    Public Class App
        Implements ICloneable

        Public Shared oApp As Framework.App = New Framework.App()






        Public Function Clone() As Object Implements System.ICloneable.Clone
            Return MyBase.MemberwiseClone()
        End Function

    End Class
Once I did the cloning, I applied a verification to make sure they were not referencing to the same pointer:
            oProcess.oApp = App.oApp.Clone()

            ' Just so we can access it directly
            oApp = oProcess.oApp

            oApp.CreateFile((oProcess.oApp Is App.oApp).ToString, oApp.cTempDir + "a.txt")
The result in a.txt file was False.

So, I assume the cloned object and the original one are not pointing to the same address.

Is this how you see it as well? If yes, does it still make sense I am not doing something properly? Or, could this be related to something else?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform