Managed C++ wrappers for legacy C++ libraries

后端 未结 5 1513
挽巷
挽巷 2020-12-14 14:02

We\'re looking at writing a .Net-callable wrapper for some legacy C++ libraries using managed C++.

It all looks pretty easy. Is there anything we need to watch out

5条回答
  •  被撕碎了的回忆
    2020-12-14 14:30

    I'll just add to what everyone has already said,

    pin_ptr wch = PtrToStringChars(string); (where string is a System::String)

    will become your friend.

    You can't directly include a non-managed class into a managed class but you can put a pointer to the unmanaged class and new it in your constructor and delete it in your destructor.

    I haven't had the problems Timo Geusch mentioned with mixing C++ and C++/CLI code in one DLL. My DLL uses both extensively without problems.

    C++/CLI is not difficult (if you know C++ and .NET) and works great.

提交回复
热议问题