ProcessForUWP.Desktop 0.1.6

dotnet add package ProcessForUWP.Desktop --version 0.1.6
                    
NuGet\Install-Package ProcessForUWP.Desktop -Version 0.1.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProcessForUWP.Desktop" Version="0.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProcessForUWP.Desktop" Version="0.1.6" />
                    
Directory.Packages.props
<PackageReference Include="ProcessForUWP.Desktop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProcessForUWP.Desktop --version 0.1.6
                    
#r "nuget: ProcessForUWP.Desktop, 0.1.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProcessForUWP.Desktop@0.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProcessForUWP.Desktop&version=0.1.6
                    
Install as a Cake Addin
#tool nuget:?package=ProcessForUWP.Desktop&version=0.1.6
                    
Install as a Cake Tool

Process for UWP

一种适用于 UWP 平台的 Process 方法

曾基于 @Silver-Fang 的项目 (Github)

LICENSE Issues Stargazers

UWP Desktop

目录

简介

本项目基于 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 项目和桌面项目都不需部署。
解决方案的启动项目应设为打包项目。

注意事项

  1. 具体使用方法请查看 Demo
  2. 请生成唯一的 UUID,避免与其他 COM 组件冲突
  3. 调用 ProcessProjectionFactory.ServerManager 前请确保已设置 ProcessProjectionFactory.CLSIDProcessProjectionFactory.ActivatableClassID
  4. OOP/WinRT 不支持沙盒与沙盒外通信,设置 uap5:RunFullTrust="true" 将只能与全权限应用通信
  5. ProcessForUWP.UWP 不支持 Native,在 .NET NativeC++ 项目中请使用 ProcessForUWP.Demo.Projection
  6. OOP/WinRT 服务器暂时不支持 .NET Framework,猜测为在 AppContainer 内会运行在 .NET Core 5.0

Star 数量统计

Star 数量统计

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.6 57 8/23/2025
0.0.5 363 3/16/2023
0.0.4 751 2/26/2022
0.0.3 517 2/19/2022
0.0.2 519 2/19/2022
0.0.1 514 2/19/2022