tags:

views:

65

answers:

2

For various reasons, such as protecting investment, etc. I need to pass a series of complex records (numerous fields and records) back and forth between Delphi and a C# program. I guess I should be using IEnumVariant, but don't seem to able to design this with the typelibrary designer.

Any help would be appreciated.

Thanks

Update

I guess what I am trying to ask needs some explanation of the complexity of the data.

I need to export to C# (or any other language really), via COM a collection of 'records', each made up of a collection of 'fields', each made up of a number of attributes.

So it is a collection of a collection of a collection! Don't ask me how we got here, we just have.

So I'm have Attribute -> Field -> Record sort of structure. I have a grasp of what I need to export (I can't post any details here for company reasons), but don't know how to start to export that data in COM.

Probably I should start by creating a test program from scratch which will mimic the structures I need, and then gradually COMize them and see where I get to.

+1  A: 

Encapsulate the info in classes. Works well in any language, works well in COM too.

Hans Passant
Except C# knows nothing about Delphi classes, and vice versa. You didn't answer the OP's question at all - the question was "how to pass complex information via COM between C# and Delphi code?". Saying "use classes" doesn't help.
Ken White
It does. Anything else is problematic. COM doesn't support structures well because their layout is so compiler dependent. Mapping a class isn't a problem, properties and methods map to a COM interface. That's glue that's built into both .NET and Delphi.
Hans Passant
A: 

I'm going to answer my own question!

I created a series of classes that dessended from IEnumVARIANT, representing the different collections of bits of data, the list and the record. Each fields was a simple COM interface definition.

I used examples from this location, although the final solution came from link text, as I implement the collections of fields / records / etc as TList.

Mmarquee