Skip to content

Setting WindowsPackageType=None should delay-load all WinAppSDK import libraries #1117

@jonwis

Description

@jonwis

@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

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions