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).
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.
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:
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.
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.
User contributions licensed under CC BY-SA 3.0