tags:

views:

243

answers:

1

We have a large vb6 application, and as we need to change/fix things, we are moving sections to .net, targeting the framework 2.0. We have moved a bunch of classes to a .net dll, and they are set up properly to be exposed to com.

Here's the problem: MainAppVB6.exe instantiates DOTNET_COM.ComClass. It passes this to a method in a differen .net dll, which passes it across an appdomain. This is no issue at all for COM objects written in vb6.

.net see the appdomain boundary, and wants the objects to be serializable or marshalbyref. Since we need the .net portion to change data that gets back to vb6, serializable doesn't work. If we mark the classes at Inherits MarshalByRefObject, then we get "This remoting proxy has no channel sink which means either the server has no registered server channels are listening, or the application has no suitable client channel to talk to the server".

There are no channels -- we are just going across an appdomain in the same dll. It seems that .net is not treating the object as COM, which it should be doing.

If I remove both marshalbyref and serializable, things work only if the com object is instantiated by vb6. If the .net functionality in the appdomain creates the object and assigns to to be passed back to vb6, vb6 gives me automation errors.

A very ugly kludge is to serialize the object in the new appdomain, send back the xml, and let vb6 deserialize, but that seems ridiculous.

Anyone have any ideas?

Thank you.

Seth

A: 

You could create a delegate to the appropriate mutator method on your COM class in your first .NET method, pass that delegate across the AppDomain boundary, use that delegate to mutate your COM object in the second .NET method and then return the mutated object back to VB6. The methods in the Marshal Class might come in handy. :)

Edit from comment: What about creating a .net copy of the vb6 class in the first .net call, passing that new object around to all the .net calls you need to make and then fix your com object going back. That might be easier than the de-serialization in vb6.

JP Alioto
That would work for a few properties, but the code in the separate appdomain has to modify dozens of properties as well as add new objects to collections. It's parsing data, populating the com object with this results, and passing it back to vb6.I'm leaning toward just having it pass back the serialization...