How to copy or deep clone vb6 comm+ proxy object in c# class?

123 Views Asked by At

I have comm+ object built in vb6 dll, what i am trying to do it read comm+ proxy object built in vb6 to map in c# class object (Getting system._ComObject)

I have added vb6 dll to reference here, vb6 dll is COM registered, i am able to access property with object.property name but i am not able to cast or clone /Map object .

I am getting system._ComObject as value, I have many interface , i am able to map by creating class but for many interface its getting difficult to create class in c# app from vb6 interface for mapping

If there is any alternate way i can get direct access to those it would be better , some how i can see values of objects rather than system._Comobject

Ideally I would like to use deepclone without reflection for comm+ proxy vb6 object ?

1

There are 1 best solutions below

0
On

The only way I know of to do this is to serialize / deserialize the VB6 COM object into a new object.

One way to do this using JSON as the intermediary is here: https://stackoverflow.com/a/52412110/3195477

Now, presumably the JSON serializer is using some reflection calls to inspect the objects & figure out how to serialize them. This implies that you could reconstruct just that portion of the logic for a more "pure" approach. (Or maybe someone has already done this).

Also note that the answer I pointed to mentions that the correct COM 'proxy' object has to be used. So it might be that if you investigate a bit more, using a tool like DeepCloner on the correct object could also work. But I haven't tried that.