Using the following Microsoft web page as a reference.. https://docs.microsoft.com/en-us/windows/msix/store-developer-package-update
I am trying to write code to update a test application I have uploaded to the Microsoft Store. Uploaded to the store is a simple dialog and a few updates (changed background color) written in C# Windows Forms using a UWP wrapper in the form of a Windows Application Packaging Project.
The dialog has a couple of buttons, one of which calls the following cut/paste methods from the above webpage..
private async void InstallUpdatesAsync() { StoreContext updateManager = StoreContext.GetDefault(); IReadOnlyList<StorePackageUpdate> updates = await updateManager.GetAppAndOptionalStorePackageUpdatesAsync(); // Save app state here IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> installOperation = updateManager.RequestDownloadAndInstallStorePackageUpdatesAsync(updates); StorePackageUpdateResult result = await installOperation.AsTask(); // Under normal circumstances, app will terminate here // Handle error cases here using StorePackageUpdateResult from above } I am getting the error..
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
Inner Exception Exception: Invalid window handle.
This function must be called from a UI thread
I don't understand this as I am calling it from a button from a dialog box. I have seen various comments elsewhere that the commands have to be called from a UI thread, but I cannot find out how.
Any help much appreciated.
https://stackoverflow.com/questions/66038811/this-function-must-be-called-from-a-ui-thread February 04, 2021 at 11:04AM
没有评论:
发表评论