P/Invoke or C++/CLI for wrapping a C library

前端 未结 6 679
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 08:45

Have a moderate size (40-odd function) C API that needs to be called from a C# project. The functions logically break up to form a few classes that will be API presented to the

6条回答
  •  悲&欢浪女
    2021-01-31 08:51

    C++/CLI will be easier to debug if you have personnel who know how to debug C++. If you don't, it could potentially be much harder.

    I would suggest that the tradeoff here is between ease of use for the consumers of your interop assembly versus ease of maintainability for the assembly itself. If you have a solid core of senior engineers who are familiar with C++ and who can reliably maintain the assembly, it will be much easier on the rest of your team who are unfamiliar with native code to give them a fully managed interface that takes care of everything for them.

    On the other hand, if you're the only person in the shop with C++ experience, I would be very leery of embedding a C++ module into the project, in case someone else has to maintain it later.

提交回复
热议问题