你们正在把它混在一起。 三种不同的办法,即与管理方案相提并论,但并非同时使用:
- pinvoke through the [DllImport] attribute. Good for C style native APIs
- interop through COM. Very well supported by the CLR as long as it is the Automation subset and you have a type library. Just works out of the box, no work needed. Adding COM to existing native code that isn t COM enabled is not productive unless you already have good COM programming skills (know ATL)
- wrapper classes created in the C++/CLI language. When the above options are not enough. Required for interop with native C++ classes.
学习足够的C++/CLI以完成这项工作需要大约3周,真正学习语言是一项多月的工作。 在你刚用它来做包装时,需要着重注意的事项是:管理“彩色”,正确使用帽子,以及“谁”与“谁”之间的区别。
了解更多情况可能值得你的时间,这些合成物与C++/CX的合成物非常相似,后者是MSVC++汇编者增加的语言延伸,支持Windows的成像。 8. 了解C++/CLI是了解C++/CX的95%。
https://stackoverflow.com/questions/2691325/c-cli-mixed-mode-dll-production/2691448#2691448>。