microsoft / microsoft/WindowsAppSDK
Missing Registry Keys Causes the Dynamic Dependencies API to Fail
@DrusTheAxe is already working on this.
Since Oct 27, 2022.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
When trying to use MddTryCreatePackageDependency to reference a framework package, if you specify a file or registry key as the artifact, the function throws an exception.
The output in Visual Studio relating to the issue starts with
```
onecore\base\appmodel\statemanager\apiset\lib\statespace.cpp(1270)\kernelbase.dll!00007FFE3CC00879: (caller: 00007FFE3CB4CE74) ReturnHr(4) tid(726c) 80070002 The system cannot find the file specified.
Msg:[Key S-1-5-21-1870781316-3806722079-920700558-1001\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.WindowsAppRuntime.1.1_8wekyb3d8bbwe\PSR]
```
Where the SID in the path is my user account's SID.
Checking the registry does show that the key that it is looking for does not exist.

Visual Studio does obtain a file from the source server. When using the Windows App SDK 1.1.5, it shows that the exception is thrown in DataStore.cpp at line 188. This is consistent regardless of the project configuration.
I have provided a project that demonstrates this. As an additional note, the package that you are trying to reference has to be installed on the system. If it isn't available then the function will fail with an element not found error, which is expected in that case. The project is hard coded to try to load WinUI 2.7, but this is not a problem with WinUI 2. I just needed a package that exists and due to the Windows Store depending on it then it has a pretty high chance of it being installed. I have tried to use other packages and it does fail with the same error with those.
The Windows 11 TryCreatePackageDependency function works without issue, so I have been able to use that for testing.
[ddlmtest.zip](https://github.com/microsoft/WindowsAppSDK/files/9843640/ddlmtest.zip)
### Steps to reproduce the bug
Build and run the project provided.
### Expected behavior
For MddTryCreatePackageDependency to successfully create a dependency using a file or a registry key as the artifact.
### Screenshots
_No response_
### NuGet package version
1.1.5
### Packaging type
Unpackaged
### Windows version
Windows 11 version 21H2 (22000)
### IDE
Visual Studio 2022
### Additional context
This also occurs with 1.2 Preview 2.
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.