title: Azure Function: load unmanaged c++ dll from c#, Error: "Unable to load DLL or one of its dependencies"
body: <p>Azure Function use unmanaged DLLs, I got the error as follows:</p>
  
  <p>"Unable to load DLL 'aa.dll' or one of its dependencies: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
  "</p>
  
  <p>with the solution proposed by <a href="https://stackoverflow.com/questions/53643543/include-c-c-unmanaged-code-dll-consumed-using-dllimport-in-azure-functions-p/57178302#57178302">Link</a>, I have successfully copied all my unmanaged DLLs to the bin folder in azure function.</p>
  
  <p>In my case, I have two c++ DLLs <strong>aa.dll</strong> and <strong>bb.dll</strong>, <strong>aa.dll</strong> depends on <strong>bb.dll</strong>, I add <strong>aa.dll</strong> as follow to my code</p>
  
  <pre><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);
  </code></pre>
  
  <p>it <strong>works perfectly fine in my visual studio locally</strong> (with azure function template), but after publish to the azure, I got the Error above. any idea? thanks a lot!</p>