How do I wrap unmanaged C++ classes so they can be consumed by .Net managed client applications?

Hi:

We have a win32 C++ unmanaged library (which calls Boost and openCV under the covers).
The library contains several public class definitions.
The classes themselves expose several methods who's parameters include vectors, shared pointers
and callbacks as part of their method signatures.

We would like to create a wrapper which would allow these classes to be consumed by .Net (managed) clients.
We want to preserve support for our existing unmanaged client applications. So I guess this will have to be
a separate DLL/library. Another consideration is performance marshaling across the managed/unmanaged
boundary. We'll be pushing byte arrays of images back and forth between the client app and libraries at
the rate of 30-50 times per second.

What is the best approach for doing this?

Can someone point me in the direction of any sample implementations, tutorials, strategies to get us started?
The last time I looked at something like this was well over 10 years ago.
I seem to vaguely remember pInvoke and the IJW works.

Any ideas would be greatly appreciated.

Thanks,
JohnB
LVL 1
jxbmaSoftware ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
Wrappers are a nice approach, but they mean writing a wrapper for every single method in all classes, which at least to me seems a bit overkill when it's not more than a handfull of classes. For a bigger amount I'd rather go for COM Interop, since it allows for a slightly more automated way to do that. To be clear: There is still quite some work to do, but you don't have to care about marshalling when it comes to passing more complex types. See https://msdn.microsoft.com/en-us/library/ms173184.aspx ("Interoperability (C# Programming Guide)") and the examples at https://msdn.microsoft.com/en-us/library/aa645712%28v=vs.71%29.aspx ("COM Interop Tutorials")
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.