Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

Copy/Clone an object.

I'm using a third party library that has methods/objects to create PDFs and to access a page in a PDF.   I want to be able to copy/clone an object that's part of this library that represents a PDF page.  Just doing an assignment from one variable to another merely references the same object.    

How can I do this?
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Something like
ob2 = ob1.Clone()
if that functionality exists in the library
Avatar of HLRosenberger

ASKER

.Clone does not exist.   And if I try to New an instance of this object, I get:  ".... Sub New(  As    ) is not accessible in this context because it is 'Friend'.
Is there a copy function in the library?
no copy either. I thought maybe there was a generic .NET way to clone any object.
There is (with a caveat) - Clone - but it needs the object to implement the ICloneable interface.

https://msdn.microsoft.com/en-us/library/system.icloneable.clone(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America 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
Unfortunately, it's not serializable.
Thanks!
>>Unfortunately, it's not serializable.

So why have you accepted that as an answer in that case?