使用.EXE创建和启动Windows Service,该服务在稀疏软件包(.msix)上具有包装身份以创建pushNotificationChannel

发布于 2025-01-22 12:57:38 字数 1064 浏览 0 评论 0原文

我是C#,.NET Core World的新手,并为我们的需求找出POC。

基本上它是使用.NET Core创建的Windows服务(如此处解释:使用背景服务创建Windows服务)。我们的目标是向Windows Service发送推送通知(原始推送通知,触发某些任务),并且正如我所理解的那样,没有办法用于非包装应用程序(没有包装身份),例如我们的Windows Service Project 。因为这是一个简单的控制台应用程序。

因此,我发现我们可以授予包装身份,这是创建推送通知频道的前提:对非包装桌面应用程序的授予身份

问题是,当我将软件包身份添加到我们的项目/.exe中时,更精确地添加了应用程序。具有msix节点的manifest到Windows Service,就不可能启动Windows Service。一切都很好,我可以执行.exe,它也可以返回我的频道URI,但是如果我创建了它的Windows服务并尝试启动它,我会收到以下错误:“ 5:访问被拒绝”。 从application.manifest中删除msix节点。但是没有包装身份,我无法获得un频道。

是的,我们确实需要Windows服务,因为这符合我们的其他想法。

甚至有可能向Windows服务上的WNS发送推送通知吗? 如果是这样,我走了正确的路,错过了一些事情,还是有另一种方法可以做?

I´m new to c#, .net core world and figuring out a POC for our needs.

Basically its a Windows Service created with .net core (like here explained: Create a Windows Service using BackgroundService). Our goal is to send push notification (raw push notification, trigger some tasks in behind) to our Windows Service and as i understood it there is no way to do it for a non-packaged application (without package identity) like our Windows Service project. Since this is a simple console application.

So i found that we can grant package identity which is precondtion for creating push notification channel, by this Doc: Grant identity to non-packaged desktop apps

But here is the problem, when i add package identity to our project/.exe, more precisely adding the application.manifest with the msix node to the Windows Service it is not more possible to start the Windows Service. Everything is fine, i can execute the .exe and it also return me the Channel URI, but if i create a Windows Service of it and try to start it, i get the following error: "5: Access denied".
Removing the msix node from the application.manifest from the project, building it new, it is possible to create and start the Windows Service. But without package identity i cant get the channel Uri.

Yes, we do need a Windows Service because this fits our other ideas.

It is even possible the send push notifications over WNS to a Windows Service?
If so, did i went the right way and missed something or is there another way to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡水深流 2025-01-29 12:57:38

在您授予软件包过程中,您是否使用了一些相对路径?
因为如果您使用一些相对路径,则可能会从目录外部运行EXE文件,因为该文件将无法工作,因为所需的文件将无法退出。

出于测试目的,如果您在一个包含exe文件的另一个目录中打开命令行并尝试运行它,它是否运行还是失败?
例如,如果您的文件是C:\ Program Files \ Test \ Test.exe。
如果您在c:\ program文件上打开命令行,并且执行。\ test \ test.exe,您是否会遇到相同的错误。

In you grant package process, did you use some relative path?
Because it's possible that if you are using some relative path, trying to run the exe file from outside of the directory where it's located won't work as the files needed won't exit.

For test purpose, if you open command line in a another directory that the one containing you exe file and try to run it, does it run or fail?
For example if your file is C:\Program Files\Test\test.exe.
If you open command line at C:\Program Files and do .\Test\test.exe do you get the same error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文