MAUI for Windows - DLLImport not finding 3rd party DLL even when its located in the Assembly Directory

Todd VanNurden 5 Reputation points
2023-11-20T03:44:49.3133333+00:00

I have a MAUI app that's targeting both Android and Windows. They use a 3rd party set of components shipped as .SO for Android and DLLs for Windows. I'm using .NET 7

I've simplified this down to just a Windows based MAUI application. Added the 3rd party DLLs to root of the project and applied a copy always attribute. When the App compiles, the appropriate BIN folder has all the components including the 3rd party DLLs.

I've also tried moving the DLLs to a .NET Core Assembly that has them copied and it also copies them to the BIN folder as expected but I get the same error.

I've also tried manipulating the DLLImportSearchPath specification to include UserDirectories with a "path" that include the directory containing the DLLS

But when the calls are attempted, the DLLs are reported as not found.

I have all the appropriate [DLLImport] attributes and I have confirmed the same MAUI app works if I call a Windows API using a DLLImport.

*I have also built the same basic calls in a WPF app and it just works. (Yes, I understand it's a different architecture, but the docs don't mention a difference when using MAUI)
*
I'm obviously missing something.

Any suggestions?

Thanks in advance

Developer technologies | .NET | .NET MAUI
Windows for business | Windows Client for IT Pros | User experience | Other
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.