Interop is the subsystem in the runtime that enables interoperability with other systems, like native C libraries or Objective-C. In some cases, it includes a full interop implementation like via P/Invoke or COM interop. In other cases, like for WinRT, it provides the building block APIs such that another (external) component can provide an end-to-end implementation.

We’re using the conversation format again, this time with four of the runtime engineers who work on interop and related topics.

What is interop and what problem does it solve? What capability would be missing without it?

Aaron: It attempts to bridge the gap between disparate platforms. In this case between .NET and the underlying platform it is running on top of. User defined interaction with the platform.

Tanner: Interop is a way to “communicate” between two different languages or platforms. Without it, we wouldn’t be able to easily depend on existing code produced by other platforms and languages and would need to rebuild it ourselves.

For example, WinForms is written in C## and is built by interoping with the Windows APIs written in C. Without interop, this would be much more difficult.

Jeremy: Interop enables .NET users to interact with non-.NET code. Without interop, users would not be able to use non-.NET libraries within their .NET applications. For example, the .NET platform would not be able to use networking, compression, or cryptography libraries written in C or C++ or provided by the platform without some form of interop.

Elinor: Interop allows interaction between different languages/platforms. Without it, we would be missing a way to use components defined outside of the current language – for example, a .NET application could not easily use a native component written in C and the .NET platform itself could not easily call operating system APIs in order to provide an abstraction over them.

#dotnet #dotnet interop

Conversation about .NET interop
1.10 GEEK