I have an UWP app that has a Service as fullTrust application. I'd like to download and install that Service if it does not exist. The download it is being performed, however I have "Access Denied" problems.
My attempts:
string command = $"powershell -executionPolicy Bypass -Command \"Add-AppxPackage -Path '{path}'\"";
ProcessStartInfo startInfo = new();
startInfo.FileName = path;
startInfo.Arguments = path;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = false;
startInfo.Verb = "runas";
Process? process = Process.Start(startInfo);
process?.WaitForExit();
An error occurred trying to start process 'C:\Users\MyUser\Documents\repos\AppServiceTest\UWPSample\bin\x64\Debug\net9.0-windows10.0.26100.0\win-x64\AppX\package47528147.msixbundle' with working directory 'C:\Users\MyUser\Documents\repos\AppServiceTest\UWPSample\bin\x64\Debug\net9.0-windows10.0.26100.0\win-x64\AppX'. The specified executable is not a valid application for this OS platform.
string command = $"powershell -executionPolicy Bypass -Command \"Add-AppxPackage -Path '{path}'\"";
PackageManager packageManager = new();
Uri uri = new(path);
var deploymentOperation = packageManager.RequestAddPackageAsync(uri, null, DeploymentOptions.None, null, null, null);
DeploymentResult depoloymentResult = await deploymentOperation;
Access is denied.
PackageManager packageManager = new();
Windows.Foundation.IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> deploymentOperation = packageManager.AddPackageAsync(
new Uri(path),
null,
DeploymentOptions.ForceTargetApplicationShutdown
);
DeploymentResult deploymentResult = await deploymentOperation;
Attempted to perform an unauthorized operation.
Obs: I cannot add another fulltrust application to my UWP, because my package service msixbundle is already a fulltrust of my UWP app. Or, is it possible add more than one fulltrust .exe to the same application?