英文:
How to run Windows App SDK packaged C# app at startup?
问题
我想要让我的打包的C#应用在登录时启动。在这篇帖子的指导下,我配置了Package.appxmanifest并将相关的代码添加到我的应用程序。然而,当用户登录时,启动画面出现,但应用程序无法启动。
帖子提到了一点:
如果您的应用启用了启动激活,您应该通过覆盖OnActivated方法在您的App类中处理这种情况。
然而,WASDK应用程序没有"OnActivated"方法。我猜问题出在这里,我想知道如何正确配置我的代码来解决这个问题。
感谢任何帮助。
英文:
I want to run my packaged c# app to start at log-in. Under the guidance of this post, I configured Package.appxmanifest and added relevant code to my app. However, when users log in, the splash screen appears but then the application fails to launch.
The post mentions one thing:
> If your app is enabled for startup activation, you should handle this
> case in your App class by overriding the OnActivated method.
However, WASDK app doesn't have an OnActivated
method. I guess the problem lies here and I wonder how to correctly configure my code to fix this issue.
Appreciate any help.
答案1
得分: 1
已解决。
根据此博客,我们应该以以下形式编写package.appxmanifest
:
<Extensions>
<uap5:Extension
Category="windows.startupTask"
Executable="SingleInstancedError.exe"
EntryPoint="SingleInstancedError.App">
<uap5:StartupTask
TaskId="SingleInstancedErrorId"
Enabled="false"
DisplayName="SingleInstancedError startup" />
</uap5:Extension>
</Extensions>
但是,为了使其适用于Windows App SDK,必须删除这两行:
Executable="SingleInstancedError.exe"
EntryPoint="SingleInstancedError.App"
这样清单看起来像这样:
<Extensions>
<uap5:Extension
Category="windows.startupTask">
<uap5:StartupTask
TaskId="SingleInstancedErrorId"
Enabled="false"
DisplayName="SingleInstancedError startup" />
</uap5:Extension>
</Extensions>
然后应用程序会在启动时正常运行。
英文:
Resolved.
According to this blog, we are supposed to write package.appxmanifest
in this form:
<Extensions>
<uap5:Extension
Category="windows.startupTask"
Executable="SingleInstancedError.exe"
EntryPoint="SingleInstancedError.App">
<uap5:StartupTask
TaskId="SingleInstancedErrorId"
Enabled="false"
DisplayName="SingleInstancedError startup" />
</uap5:Extension>
</Extensions>
However, to make it work for Windows App SDK, these two lines must be removed:
Executable="SingleInstancedError.exe"
EntryPoint="SingleInstancedError.App"
So that the manifest looks like this:
<Extensions>
<uap5:Extension
Category="windows.startupTask">
<uap5:StartupTask
TaskId="SingleInstancedErrorId"
Enabled="false"
DisplayName="SingleInstancedError startup" />
</uap5:Extension>
</Extensions>
And the app runs normally at startup.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论