How to use unmanaged dll in .net project?

I am working on an ASP.NET project that generates screenshots. I want to use gdi32.dll in my project. How to import it?

+4
source share
3 answers

You need to use P / Invoke .

+6
source

If the dll is a system dll, you should add it like this programmatically:

[DllImport("gdi32.dll", CharSet = CharSet.Ansi, BestFitMapping = true, ThrowOnUnmappableChar = true)]

And make sure that the project ( Platform Solution ) is set to 32 or x86 , and not any CPU. You can find more about this with a simple Google search . Happy coding

0
source

You can use the C ++ / CLI wrapper, depending on your requirements. This makes some things easier.

0
source

All Articles