microsoft / microsoft/WindowsAppSDK
Incompatibility between WindowsAppRuntime.dll and SetDefaultDllDirectories
@DrusTheAxe is already working on this.
Since Feb 24, 2025.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
Hello, we are using WindowsAppRuntime (indirectly) from an winui3 desktop application. We noticed that the application does not start when calling [SetDefaultDllDirectories](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-setdefaultdlldirectories). I managed to track the issue to [this](https://github.com/microsoft/WindowsAppSDK/blob/v1.5.3/dev/UndockedRegFreeWinRT/catalog.cpp#L50) LoadLibraryExW call when calling it with a relative path (`dcompi.dll` during my tests)
).
The documentation of LoadLibraryExW states about `LOAD_WITH_ALTERED_SEARCH_PATH` that:
> If this value is used and lpFileName specifies a relative path, the behavior is undefined.
A minimally reproducible example of the behavior (without the entire winui infrastructure, just for demonstration purposes):
```
int main()
{
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
HMODULE mod = LoadLibraryExW(L"dcompi.dll", nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
return 0;
}
```
### Steps to reproduce the bug
Run any WindowsAppRuntime app that calls SetDefaultDllDirectories. It should just work.
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
None
### Packaging type
_No response_
### Windows version
_No response_
### IDE
Visual Studio 2022
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.