Trying to load unmmanaged c++ dll in azure

0

I'm trying to call to my unmanaged dll from my asp.net mvc web app. when I call this dll from localhost it work just fine. when publish the app to azure and try to call this dll I'm getting this:

Error:System.DllNotFoundException: Unable to load DLL 'SerenityConfigCodec.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A).

  1. I succeed to call to a simple dll in azure (not mine). According to Microsoft azure documentation.
  2. I use a dependency walker on my dll to know the dlls that I need in azure and add them.

I have some theory that my dll need some extra dll in azure that dependency walker not tell me about them. Or maybe I need to connect my website to iis and try to use iisreset to cause maybe the .bin folder in azure get into locked at run time and let iisreset unlock it.

c++
asp.net-mvc
azure
dll
asked on Stack Overflow Dec 29, 2015 by ozsh83 • edited Jan 1, 2016 by tereško

2 Answers

0

Sounds like Azure cannot find your referenced DLL.

Is this DLL added as a Dependency in your project? or as a Nuget package?.

If it's a Dependency there two possible solutions depending on your publishing method:

  • Add the Copy Local to True if you are publishing using Web Deploy (Right-click > Publish from Visual Studio)
  • If you are publishing through Continuous Integration and a link to a repository (GitHub / Bitbucket / VSO / etc), add the DLL file to your repository (maybe in a folder especifically for that) and reference it in your project using that folder path.

If it's a Nuget package, it will fail if you are using Web Deploy (unless you set the Copy Local to True), if you are deploying through Continuous Integration, Kudu takes care of downloading all the packages on the deployment process.

answered on Stack Overflow Dec 29, 2015 by Matias Quaranta
0

I solved this problem by adding the compiled unmanaged DLL file to the managed project, so it would be included in the publish package. Since the added file was either the debug or release DLL I had to manually edit the .csproj file to conditionally copy either the debug or release build DLL depending on if I'm building the debug or release managed DLL. This in turn generates warnings every time I load the project but the builder handles it right. And I need to remember to rebuild the managed DLL to get it to pick up on changes to the unmanaged DLL since it hasn't been doing that for me automatically.

Depending on which version of VS you're using you may need to install the C++ runtime DLLs as well.

The 0x8007045A error indicates that the DLL was found but init failed, while the 0x8007007E error mentioned an a comment to another answer indicates that it couldn't find the DLL to load.

answered on Stack Overflow Dec 30, 2015 by 1201ProgramAlarm

User contributions licensed under CC BY-SA 3.0