I have a few native C++ libraries and such that I need to expose to managed (C#, in this case) code. I need to get as much speed out of it as possible.
I wou开发者_如何学运维ld like to use some classes to simplify the interaction, which means mixed code, but that's not a requirement.
What is a requirement is that it be cross-platform compatible, to Windows and Linux at worst. Thus, standard /clr is out of the question.
My options are either /clr:pure or /clr:safe, or embedding Mono into a go-between layer. My question is which will be better (best performance and ease of development and later use).
The libraries I need to work with make heavy use of pointers and occasionally shared pointers, which made me think the C++/CLI layer would be easier. I wrote a simple app testing use of some objects and compiled it with /clr:pure, it didn't link into the native module but did run under both Windows and Linux.
Use P/Invoke.
Using 'pure' will make it a lot slower from what I have seen, especially number crunching stuff (encryption).
精彩评论