rkb771
Member
- Joined
- Jun 21, 2022
- Messages
- 6
- Programming Experience
- Beginner
Simply put, I have a c# code for UI and a native c++ dll for calculation. The dll is compiled for 64-bit with gcc 11.2. I am using MSVS 2022 for the UI. Selected .NET version is 4.8. The import is done with LoadLibrary, GetProcessAdress and Delegate.
The c++ functions are exported as,
The c# code is
On my laptop, running windows 10, the UI runs fine. Loads the dll, imports all function, calls those functions, gets returns. I can run it on a different PC too (Windows 10). But when I sent the app to my boss, she couldn't run it. Her PC is running Windows 11 and has VS 2022 installed. She tried compiling and running the source code and got error at dll import. I checked the project clone in her PC which is exactly the same as mine. There is nothing wrong with path. But LoadLibrary returns null and the ErrorCode is 126. I tried installing Windows 10 and 11 SDKs, didn't help.
I also supplied the known dependencies "libgcc", "libstdc++", "libwinpthread". Using Dependency Walker, I can't find any other dependency that could be missing from windows other than these three.
My guess is that Windows 11 is missing some dependency I don't know of. But I couldn't find any missing dependency or solution online. It would be great help if someone could point out what could be going wrong.
The c++ functions are exported as,
C++:
extern "C"{
__declspec(dllexport) ReturnType __stdcall FunctionName(Arguments)
{
//body
}
}
The c# code is
C#:
IntPtr module = LoadLibrary(DllFilePath);
if(IntPtr == null)
{
int ErrorCode = Marshal.GetLastWin32Error();
}
On my laptop, running windows 10, the UI runs fine. Loads the dll, imports all function, calls those functions, gets returns. I can run it on a different PC too (Windows 10). But when I sent the app to my boss, she couldn't run it. Her PC is running Windows 11 and has VS 2022 installed. She tried compiling and running the source code and got error at dll import. I checked the project clone in her PC which is exactly the same as mine. There is nothing wrong with path. But LoadLibrary returns null and the ErrorCode is 126. I tried installing Windows 10 and 11 SDKs, didn't help.
I also supplied the known dependencies "libgcc", "libstdc++", "libwinpthread". Using Dependency Walker, I can't find any other dependency that could be missing from windows other than these three.
My guess is that Windows 11 is missing some dependency I don't know of. But I couldn't find any missing dependency or solution online. It would be great help if someone could point out what could be going wrong.
Last edited: