Azure Function: load unmanaged c++ dll from c#, Error: "Unable to load DLL or one of its dependencies"

2

Azure Function use unmanaged DLLs, I got the error as follows:

"Unable to load DLL 'aa.dll' or one of its dependencies: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) "

with the solution proposed by Link, I have successfully copied all my unmanaged DLLs to the bin folder in azure function.

In my case, I have two c++ DLLs aa.dll and bb.dll, aa.dll depends on bb.dll, I add aa.dll as follow to my code

[DllImport(@"aa.dll", EntryPoint = "StartCode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
    [return: MarshalAs(UnmanagedType.BStr)]
    internal static extern string StartCode([MarshalAs(UnmanagedType.BStr)] string strXmlImp, int nId);

it works perfectly fine in my visual studio locally (with azure function template), but after publish to the azure, I got the Error above. any idea? thanks a lot!

azure-functions
dllimport
asked on Stack Overflow Jul 24, 2019 by Christian Ma • edited Jul 24, 2019 by Christian Ma

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0