DLLImport attribute

The attribute, [DllImport()], falls under the DllImportAttribute class. It provides the information required to call a function exported from an unmanaged DLL. The minimum prerequisite is that we should pass the name of the DLL which contains the entry point. We can apply this attribute straightforwardly to C# and C++ function definitions. Let's check what the DllImport attribute has inside it. In the code window, click on DllImport and press the F12 key (referred to as the go-to definition). This key is bound to the de-compile command in Visual Studio and will de-compile the selected type, if it can. Upon de-compilation, Visual Studio will display the de-compiled code in a new window. In the de-compiled code of DllImport ...

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.