mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
Fix for the issue where PT Run was preventing UWP apps from building in VS (#5109)
* We should not deny other processes access to this item * added a catch block for argument exception * using memory stream instead of URI * removed denyNone as it is the default config
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Plugin.Program.Logger;
|
using Microsoft.Plugin.Program.Logger;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Package = Windows.ApplicationModel.Package;
|
using Package = Windows.ApplicationModel.Package;
|
||||||
|
|
||||||
@@ -32,22 +33,26 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public static PackageWrapper GetWrapperFromPackage(Package package)
|
public static PackageWrapper GetWrapperFromPackage(Package package)
|
||||||
{
|
{
|
||||||
|
string path;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new PackageWrapper(
|
path = package.InstalledLocation.Path;
|
||||||
package.Id.Name,
|
|
||||||
package.Id.FullName,
|
|
||||||
package.Id.FamilyName,
|
|
||||||
package.IsFramework,
|
|
||||||
package.IsDevelopmentMode,
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new PackageWrapper(
|
||||||
|
package.Id.Name,
|
||||||
|
package.Id.FullName,
|
||||||
|
package.Id.FamilyName,
|
||||||
|
package.IsFramework,
|
||||||
|
package.IsDevelopmentMode,
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
IStream stream;
|
IStream stream;
|
||||||
const uint noAttribute = 0x80;
|
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);
|
var hResult = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream);
|
||||||
|
|
||||||
if (hResult == Hresult.Ok)
|
if (hResult == Hresult.Ok)
|
||||||
@@ -646,7 +646,16 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
if (File.Exists(path))
|
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;
|
return image;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -676,7 +685,6 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
private enum Stgm : uint
|
private enum Stgm : uint
|
||||||
{
|
{
|
||||||
Read = 0x0,
|
Read = 0x0,
|
||||||
DenyWrite = 0x20,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Hresult : uint
|
private enum Hresult : uint
|
||||||
|
|||||||
Reference in New Issue
Block a user