Interoperability, or interop as it is usually called, refers to using or invoking program code from some other programming environment or language, for example, calling COM or native C++ code from a managed language. Interop is a complex but extremely necessary thing. Many people think that the C++/CLI language for the .NET platform would be used primarily to extend existing code bases written in native C++. While there is no reason why you could not use C++/CLI as your .NET language of choice, the support that C++/CLI provides for native code interop on the .NET platform is indeed impressive. In many cases, you simply turn on the /clr compiler option and recompile your native code, producing managed code (or at least mixed code that’s mostly MSIL but with a few native x86 or x64 instructions mixed in). This feature was called IJW or “it just works” when it was originally released along with Managed Extensions for C++. And for the most part, it was true. It’s now called mixed mode. A huge amount of work went into making that type of interop possible. Also, even if you’re writing an entirely new managed application that uses a native API, such as Win32, interop support in C++ makes it easier and much faster to call these APIs in C++ than it is in C#.
KeywordsNative Function Pure Mode Calling Convention Context Switch Native Class
Unable to display preview. Download preview PDF.