Background
This may be incredibly basic, or it may be completely impossible. Being new to COM, I don’t know, and given my limited COM vocabulary, Google has failed me.
I have an ATL/MFC C++ COM object with many data structures defined internally.
I also have a C# project that references this COM object. In C#, I can call the methods exposed via the C++ side .IDL file and get valid results (finally!).
Question
I would like to use the .IDL file to somehow expose the 100 or so C++ data structures to C# (preferably without wrapping each one individually). Then in C#, I would simply populate the appropriate structure and call a COM method passing the data structure into C++.
Basically, I want to reuse the already defined C++ structures in C#. Is this possible? If so, how?
If it matters, I’m using Visual Studio 2010 and .NET 4 Framework.
Thanks a bunch.
So it turns out I was trying to put the structure in the wrong place in the IDL file. I was trying to add it to the
librarydefinition, and for whatever reason, that did not work.Placing it in the interface definition ended up working well :
This does not answer the question of what to do if your type does not map 1:1 to a C# type, but at least I can use the C++ defined structures in C#.