ProcessForUWP.Desktop
0.1.6
dotnet add package ProcessForUWP.Desktop --version 0.1.6
NuGet\Install-Package ProcessForUWP.Desktop -Version 0.1.6
<PackageReference Include="ProcessForUWP.Desktop" Version="0.1.6" />
<PackageVersion Include="ProcessForUWP.Desktop" Version="0.1.6" />
<PackageReference Include="ProcessForUWP.Desktop" />
paket add ProcessForUWP.Desktop --version 0.1.6
#r "nuget: ProcessForUWP.Desktop, 0.1.6"
#:package ProcessForUWP.Desktop@0.1.6
#addin nuget:?package=ProcessForUWP.Desktop&version=0.1.6
#tool nuget:?package=ProcessForUWP.Desktop&version=0.1.6
Process for UWP
一种适用于 UWP 平台的 Process 方法
曾基于 @Silver-Fang 的项目 (Github)
目录
简介
本项目基于 OOP/COM
(Out-of-Process
) 通信机制实现了 UWP 平台下的 Process
类,支持大部分常用方法和属性。目前仍在开发当中,如果有兴趣欢迎加入。
如何使用
在你的解决方案中添加一个打包项目和一个空白桌面应用项目。在打包项目中引用你的 UWP 项目和桌面应用项目。在 UWP 项目中引用 ProcessForUWP.UWP
,在桌面应用项目中引用 ProcessForUWP.Desktop
。
OOP/COM 通信
在打包项目的
Package.appxmanifest
中添加:<Package ... xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10" IgnorableNamespaces="... com"> ... <Applications> <Application> ... <Extensions> ... <com:Extension Category="windows.comServer"> <com:ComServer> <com:ExeServer Executable="【桌面应用项目的路径,如:ProcessForUWP.Demo.Delegate\ProcessForUWP.Demo.Delegate.exe】" DisplayName="ProcessForUWP Delegate" LaunchAndActivationPermission="O:SYG:SYD:(A;;11;;;WD)(A;;11;;;RC)(A;;11;;;AC)(A;;11;;;AN)S:P(ML;;NX;;;S-1-16-0)"> <com:Class Id="【自行生成的唯一 GUID】" DisplayName="ProcessForUWP Delegate" /> </com:ExeServer> </com:ComServer> </com:Extension> </Extensions> </Application> </Applications> ... </Package>
在桌面项目的
Program.cs
中添加:internal class Program { private static void Main(string[] args) { ... Factory.StartComServer(new Guid("【自行生成的唯一 GUID】")); } ... }
在 UWP 项目中使用前添加:
ProcessProjectionFactory.CLSID = new Guid("【自行生成的唯一 GUID】");
WinRT/COM 通信 (不支持沙盒与沙盒外通信)
在打包项目的
Package.appxmanifest
中添加:<Package ...> ... <Extensions> ... <Extension Category="windows.activatableClass.outOfProcessServer"> <OutOfProcessServer ServerName="wherewhere.ProcessForUWP.Delegate"> <Path>【桌面应用项目的路径,如:ProcessForUWP.Demo.Delegate\ProcessForUWP.Demo.Delegate.exe】</Path> <Instancing>singleInstance</Instancing> <ActivatableClass ActivatableClassId="【自行选择唯一的字符串 ID】" /> </OutOfProcessServer> </Extension> </Extensions> ... </Package>
在桌面项目的
Program.cs
中添加:internal class Program { private static void Main(string[] args) { ... Factory.StartWinRTServer(new Guid("【自行选择唯一的字符串 ID】")); } ... }
在 UWP 项目中使用前添加:
ProcessProjectionFactory.DefaultType = RPCType.WinRT; ProcessProjectionFactory.ActivatableClassID = new Guid("【自行选择唯一的字符串 ID】");
在 UWP 项目中即可使用 RemoteProcess
类:
IProcessStatic process = ProcessProjectionFactory.ServerManager.ProcessStatic;
RemoteProcessStartInfo info = new("cmd")
{
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
RemoteProcess _process = process.Start(info);
_process.OutputDataReceived += OnOutputDataReceived;
_process.ErrorDataReceived += OnErrorDataReceived;
_process.BeginErrorReadLine();
_process.BeginOutputReadLine();
在解决方案配置管理器中,三个项目的平台需保持一致。生成都要勾选。部署只需勾选打包项目,UWP 项目和桌面项目都不需部署。
解决方案的启动项目应设为打包项目。
注意事项
- 具体使用方法请查看 Demo
- 请生成唯一的 UUID,避免与其他 COM 组件冲突
- 调用
ProcessProjectionFactory.ServerManager
前请确保已设置ProcessProjectionFactory.CLSID
或ProcessProjectionFactory.ActivatableClassID
- OOP/WinRT 不支持沙盒与沙盒外通信,设置
uap5:RunFullTrust="true"
将只能与全权限应用通信 ProcessForUWP.UWP
不支持 Native,在.NET Native
或C++
项目中请使用 ProcessForUWP.Demo.Projection- OOP/WinRT 服务器暂时不支持
.NET Framework
,猜测为在 AppContainer 内会运行在.NET Core 5.0
上
Star 数量统计
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows10.0.17763 is compatible. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows10.0.17763 is compatible. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap10.0.15138 is compatible. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- ProcessForUWP.Core (>= 0.1.6)
-
.NETFramework 4.5
- ProcessForUWP.Core (>= 0.1.6)
-
.NETFramework 4.6.1
- ProcessForUWP.Core (>= 0.1.6)
-
.NETStandard 2.0
- ProcessForUWP.Core (>= 0.1.6)
-
.NETStandard 2.1
- ProcessForUWP.Core (>= 0.1.6)
-
net6.0-windows10.0.17763
- ProcessForUWP.Core (>= 0.1.6)
-
net8.0-windows10.0.17763
- ProcessForUWP.Core (>= 0.1.6)
-
UAP 10.0.15138
- ProcessForUWP.Core (>= 0.1.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.