Fix "Element not found" error during settings loading (#12687)
This commit fixes a stray exception during settings loading, caused by a failure to obtain the app's extension catalog. ## PR Checklist * [x] Closes #12305 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed I'm unable to replicate the issue. ❌ However an error log was provided in #12305 with which the function causing the exception could be determined.
This commit is contained in:
parent
f0c2ef361a
commit
9c6ec75082
|
@ -2575,6 +2575,7 @@ uuidv
|
|||
UVWX
|
||||
UVWXY
|
||||
UWA
|
||||
UWAs
|
||||
uwp
|
||||
uxtheme
|
||||
vals
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "DefaultTerminal.h"
|
||||
#include "FileUtils.h"
|
||||
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Windows::ApplicationModel::AppExtensions;
|
||||
using namespace winrt::Microsoft::Terminal::Settings;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model::implementation;
|
||||
|
||||
|
@ -235,10 +237,29 @@ void SettingsLoader::FindFragmentsAndMergeIntoUserSettings()
|
|||
}
|
||||
}
|
||||
|
||||
// Search through app extensions
|
||||
// Gets the catalog of extensions with the name "com.microsoft.windows.terminal.settings"
|
||||
const auto catalog = winrt::Windows::ApplicationModel::AppExtensions::AppExtensionCatalog::Open(AppExtensionHostName);
|
||||
const auto extensions = extractValueFromTaskWithoutMainThreadAwait(catalog.FindAllAsync());
|
||||
// Search through app extensions.
|
||||
// Gets the catalog of extensions with the name "com.microsoft.windows.terminal.settings".
|
||||
//
|
||||
// GH#12305: Open() can throw an 0x80070490 "Element not found.".
|
||||
// It's unclear to me under which circumstances this happens as no one on the team
|
||||
// was able to reproduce the user's issue, even if the application was run unpackaged.
|
||||
// The error originates from `CallerIdentity::GetCallingProcessAppId` which returns E_NOT_SET.
|
||||
// A comment can be found, reading:
|
||||
// > Gets the "strong" AppId from the process token. This works for UWAs and Centennial apps,
|
||||
// > strongly named processes where the AppId is stored securely in the process token. [...]
|
||||
// > E_NOT_SET is returned for processes without strong AppIds.
|
||||
IVectorView<AppExtension> extensions;
|
||||
try
|
||||
{
|
||||
const auto catalog = AppExtensionCatalog::Open(AppExtensionHostName);
|
||||
extensions = extractValueFromTaskWithoutMainThreadAwait(catalog.FindAllAsync());
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
if (!extensions)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& ext : extensions)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue