does azure website support p/invoke to load native c++ dll

Azure websites can also load native dlls. I just made it work.

Here are the steps (referred from here):

  1. Compile your solution.

  2. Right click on the managed project and select "Add/Existing Item". Do not use "Add Reference".

  3. Navigate to your compiled native DLL and select it (adjust file types as needed).

  4. Click on the down arrow in the "Add" split button and select "Add As Link".

  5. Right click on that freshly added file and select "Properties".

  6. Make sure "Build Action" is "Content" and "Copy To Output Directory" is set to "Copy always" or "Copy if newer".

Note: in step 2, you should right click on the project, so that the dll will be copied to the bin folder, and uploaded to Azure server. If you put it in some folder instead of under the project directly, the dll will be copied to /bin/somefolder, which is still invisible.

Hope this helps.


You can load a native DLL, but there are some requirements. First, it must be targeting x64, not x86.

Also, you must build it against the proper toolset:

By default, only the Visual C++ runtime libraries for Visual C++ 2008 are installed on Windows Azure worker and web roles. Therefore, native code compiled against the Visual C++ runtime library for Visual C++ 2010 or Visual C++ 2005 will fail to load in worker and web role instances. If you have both Visual Studio 2008 and Visual Studio 2010 installed on the same computer you can use the native multi-targeting feature of Visual Studio 2010 to build native libraries for your application with the Visual Studio 2008 platform toolset (compiler, linker, headers, and libraries). For more information about using Visual Studio 2010 to build an application with the Visual Studio 2008 platform toolset see C++ Native Multi-Targeting (http://go.microsoft.com/fwlink/p/?LinkId=231170).

Alternatively, you can setup a startup task that runs elevated which copies the requirements for your native DLL onto the server.