I have a UWP c# app which calls a native C++ DLL named DLL2.dll and DLL2.dll calls another native C++ DLL named DLL1.dll. I put these two dll into a folder named library and the UWP project included this folder, selecting "copy always" in "Copy to output directory" and "content" in "Build action". In .cs file:(Dll2Init will call Dll1Init)
[DllImport("library/Dll1.dll", EntryPoint = "DLL1Init", CharSet = CharSet.Unicode)]
public static extern void DLL1Init();
[DllImport("library/Dll2.dll", EntryPoint = "DLL2Init", CharSet = CharSet.Unicode)]
public static extern void DLL2Init();//this function will call DLL1Init()
public MainPage()
{
this.InitializeComponent();
//DLL1Init();//will run well call DLL1Init before Dll2Init
DLL2Init();
}
When I run c#, it says "Unable to load DLL 'library/Dll2.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)". I have checked that Dll1.dll and Dll2.dll are already copied into App\bin\x64\Debug\AppX\library. And I do some tests:
From above, it seems that when app calls dll which doesn't call other third-party dll.The dll could be in any directory in case that it DllImport it. But if the c++ dll call another Dll, these DLLs only be put into the same directory with app. It's really strange. Do I miss something? The sample is at here
User contributions licensed under CC BY-SA 3.0