ProcessForUWP.Desktop
0.0.5
dotnet add package ProcessForUWP.Desktop --version 0.0.5
NuGet\Install-Package ProcessForUWP.Desktop -Version 0.0.5
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.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ProcessForUWP.Desktop --version 0.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProcessForUWP.Desktop, 0.0.5"
#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.
// Install ProcessForUWP.Desktop as a Cake Addin
#addin nuget:?package=ProcessForUWP.Desktop&version=0.0.5
// Install ProcessForUWP.Desktop as a Cake Tool
#tool nuget:?package=ProcessForUWP.Desktop&version=0.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Process for UWP
一种适用于 UWP 平台的 Process 方法
基于 @Silver-Fang 的项目 (Github)
目录
简介
本项目基于 @Silver-Fang 的项目 ProcessForUWP,与其不同的是,本项目利用了通信接口 AppServiceConnection
来进行应用间的通信,所以不用执行一次就弹一次 UAC,但是使用起来会比较麻烦。目前仍在开发当中,如果有兴趣欢迎加入。
如何使用
在你的解决方案中添加一个打包项目和一个空白桌面应用项目。在打包项目中引用你的 UWP 项目和桌面应用项目。在 UWP 项目中添加引用 ProcessForUWP.UWP
,在桌面应用项目中引用 ProcessForUWP.Desktop
。
然后在打包项目的 Package.appxmanifest
中添加:
<Package
...
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap rescap desktop">
...
<Applications>
<Application>
...
<Extensions>
<uap:Extension Category="windows.appService">
<uap:AppService Name="ProcessForUWP.Delegate"/>
</uap:Extension>
<desktop:Extension Category="windows.fullTrustProcess" Executable="【桌面应用项目的路径,如:ProcessForUWP.Demo.Delegate\ProcessForUWP.Demo.Delegate.exe】" />
</Extensions>
</Application>
</Applications>
...
</Package>
在 UWP 项目的 App.xaml.cs
中添加:
public sealed partial class App : Application
{
...
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
Communication.InitializeAppServiceConnection();
...
}
/// <summary>
/// Handles connection requests to the app service
/// </summary>
/// <param name="args">Data about the background activation.</param>
protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
base.OnBackgroundActivated(args);
Communication.OnBackgroundActivated(args);
}
}
在桌面项目的 Program.cs
中添加:
internal class Program
{
private static void Main(string[] args)
{
Communication.InitializeAppServiceConnection();
...
EventWaitHandle WaitHandle = new AutoResetEvent(false);
_ = WaitHandle.WaitOne();
}
...
}
在解决方案配置管理器中,三个项目的平台需保持一致,建议都设为x64。生成都要勾选。部署只需勾选打包项目,UWP 项目和桌面项目都不需部署。
解决方案的启动项目应设为打包项目。
注意事项
- 具体使用方法请查看 Demo
- 请不要在应用初始化过程中新建 Process 类,虽然我已经做了未加载完成的判断,但是这个判断可能会占用了线程导致应用初始化无法完成,如果真的要在应用初始化时新建 Process 类,请把它挪到别的线程去,或者提出 issue 帮助我解决这个问题。
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.18362 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. |
.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 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
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.
-
.NETCoreApp 3.1
- Microsoft.Windows.SDK.Contracts (>= 10.0.22621.755)
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
- System.Runtime.WindowsRuntime (>= 4.7.0)
- System.ValueTuple (>= 4.5.0)
-
.NETFramework 4.6.2
- Microsoft.Windows.SDK.Contracts (>= 10.0.22621.755)
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
-
.NETFramework 4.8.1
- Microsoft.Windows.SDK.Contracts (>= 10.0.22621.755)
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
-
.NETStandard 2.0
- Microsoft.Windows.SDK.Contracts (>= 10.0.22621.755)
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
-
net6.0-windows10.0.18362
- Newtonsoft.Json (>= 13.0.3)
- ProcessForUWP.Core (>= 0.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.