O'Reilly logo

.NET Core 2.0 By Example by Neha Shrivastava, Rishabh Verma

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

Interop with existing native libraries with example

Let's create DLL and create a header file (.h) inside it using C++, and we will see how we can consume it in our .NET Core application. In the following example, we created a DLL project for example, calling it ExampleDLL. Create a source .cpp file and a header file. Open the header file and write the following code, which returns the sum of two values. To consume public data and functions in class, we have to add the keyword _declspec(dllexport) before the public member which we want to consume from outside. While creating a DLL, we usually add the header file which contains the function or class prototype and we can export this using the __declspec(dllexport) keyword, while doing a declaration ...

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