diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs index 24043b0990..fa153d819e 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs @@ -1,4 +1,5 @@ using Microsoft.Plugin.Program.Logger; +using System; using System.IO; using Package = Windows.ApplicationModel.Package; @@ -32,22 +33,26 @@ namespace Microsoft.Plugin.Program.Programs public static PackageWrapper GetWrapperFromPackage(Package package) { + string path; try { - return new PackageWrapper( - package.Id.Name, - package.Id.FullName, - package.Id.FamilyName, - package.IsFramework, - package.IsDevelopmentMode, - package.InstalledLocation.Path - ); + path = package.InstalledLocation.Path; } - catch(FileNotFoundException ex) + catch (Exception e) when (e is ArgumentException || e is FileNotFoundException) { - ProgramLogger.LogException($"PackageWrapper", "GetWrapperFromPackage","package.InstalledLocation.Path",$"File Not Found for package {package.Id.Name}", ex); + ProgramLogger.LogException($"PackageWrapper", "GetWrapperFromPackage", "package.InstalledLocation.Path", $"Exception {package.Id.Name}", e); return new PackageWrapper(); } + + return new PackageWrapper( + package.Id.Name, + package.Id.FullName, + package.Id.FamilyName, + package.IsFramework, + package.IsDevelopmentMode, + path + ); + } } } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs index 3b16381203..47fac6c6da 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs @@ -58,7 +58,7 @@ namespace Microsoft.Plugin.Program.Programs IStream stream; const uint noAttribute = 0x80; - const Stgm exclusiveRead = Stgm.Read | Stgm.DenyWrite; + const Stgm exclusiveRead = Stgm.Read; var hResult = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream); if (hResult == Hresult.Ok) @@ -646,7 +646,16 @@ namespace Microsoft.Plugin.Program.Programs { if (File.Exists(path)) { - var image = new BitmapImage(new Uri(path)); + MemoryStream memoryStream = new MemoryStream(); + + byte[] fileBytes = File.ReadAllBytes(path); + memoryStream.Write(fileBytes, 0, fileBytes.Length); + memoryStream.Position = 0; + + var image = new BitmapImage(); + image.BeginInit(); + image.StreamSource = memoryStream; + image.EndInit(); return image; } else @@ -676,7 +685,6 @@ namespace Microsoft.Plugin.Program.Programs private enum Stgm : uint { Read = 0x0, - DenyWrite = 0x20, } private enum Hresult : uint