Native dll in c# web app

Benjamin Gilbert bgilbert at cs.cmu.edu
Wed Jun 15 17:18:33 EDT 2016


On Wed, Jun 15, 2016 at 02:48:47PM +0000, Peter via openslide-users wrote:
> The 20 dlls are
> 
> [...]
> 
> Maybe I miss one?

Hi Peter,

You don't need openslide-jni.dll, since that's only used by OpenSlide Java. 
The rest of the list looks correct.

> How can I DllImport those libraries? E.g. which function provides libcairo-2.dll?
> 
> [DllImport("libcairo-2.dll")]
> private static extern whichFunctionshouldBeHere(WhichArguments);

I believe you should only need to DllImport the functions you need from
libopenslide-0.dll.  The rest of the DLLs are referenced by
libopenslide-0.dll and should be loaded automatically.

For the DLLs to be loaded at runtime, they need to be on your DLL search
path.  Googling turns up some references that claim that the bin directory
of a web project is *not* on the search path.  You can test this by putting
the DLLs on the search path manually, e.g. by copying them to the Windows
directory.  (Of course, that's not something you should do in regular use.)

Sebastian is correct, by the way, that you'll need to specify the cdecl
calling convention in your DllImport attributes.

--Benjamin Gilbert


More information about the openslide-users mailing list