O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 37. System.Runtime.InteropServices

The types in this namespace work with unmanaged code using either PInvoke or COM. PInvoke (short for Platform Invoke) lets you access functions that reside in underlying operating system-specific shared libraries (on Win32, these are DLLs). COM (Component Object Model) is a Win32 legacy component architecture that is used throughout Windows and Windows applications. Many programmers experience COM through the object models of applications such as Microsoft Office, Exchange, and SQL Server. The COM support in .NET lets you access COM components as though they were native .NET classes. For an overview of PInvoke, see Chapter 17 and Chapter 18.

Many of the types in this namespace are custom attributes. For information on how the flags and properties of a custom attribute map to its actual, see Chapter 14.

We have omitted some of the more esoteric parts of this namespace, so there are some classes that aren’t discussed here. For the most part, you will not need those classes unless you are developing specialized code that handles marshaling data types between managed and unmanaged code. If so, you should consult the MSDN .NET reference materials. Figure 37-1 and Figure 37-2 show the types in this namespace.

The System.Runtime.InteropServices namespace

Figure 37-1. The System.Runtime.InteropServices namespace

Figure 37-2. Attributes and delegates from System.Runtime.InteropServices

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required