@niklasb-ms discovered that using WinAppSDK from an unpackaged app using dynamic dependencies can cause the exe to fail to launch with a "module not found" error. This appears to be caused by the exe getting a static-import record for dwritecore.dll, which isn't in the loader's paths until MddBoostrapInitialize is called. Switching to a LoadLibrary or a DELAYLOAD import of the DLL works fine.
So:
- Unpackaged (like MSI) using WinAppSDK (any version)
- App calls
DWriteCoreCreateFactory in its WinMain
- App crashes at launch with
ERROR_MOD_NOT_FOUND
Potential solution:
When the project has <WindowsPackageType>None</WindowsPackageType> all WinAppSDK DLLs should be delay-loaded. This can be done with by adding a /delayload:dllname linker option, per https://docs.microsoft.com/en-us/cpp/build/reference/linker-support-for-delay-loaded-dlls?view=msvc-160
@niklasb-ms discovered that using WinAppSDK from an unpackaged app using dynamic dependencies can cause the exe to fail to launch with a "module not found" error. This appears to be caused by the exe getting a static-import record for dwritecore.dll, which isn't in the loader's paths until
MddBoostrapInitializeis called. Switching to aLoadLibraryor aDELAYLOADimport of the DLL works fine.So:
DWriteCoreCreateFactoryin itsWinMainERROR_MOD_NOT_FOUNDPotential solution:
When the project has
<WindowsPackageType>None</WindowsPackageType>all WinAppSDK DLLs should be delay-loaded. This can be done with by adding a/delayload:dllnamelinker option, per https://docs.microsoft.com/en-us/cpp/build/reference/linker-support-for-delay-loaded-dlls?view=msvc-160