个人资料

跳过导航链接首页 > 博客列表 > 博客正文

桌面桥设置wpf应用自启动的几个坑

:

1.打包错误

添加应用自启动,修改Package.appxmanifest添加下面代码后


      <Extensions>
        <desktop:Extension Category="windows.startupTask" Executable="CPU Meter.exe" EntryPoint="Windows.FullTrustApplication">
          <desktop:StartupTask TaskId="Win32appTask" Enabled="true" DisplayName="CPU Performance Meter" />
        </desktop:Extension>
      </Extensions>


打包报错,找不到xxx.ExE.

解决办法:找到桌面桥项目.用记事本打开.wapproj文件.

ItemGroup节点下面,把exe文件加进去,修改后如下


  <ItemGroup>
    <None Include="Package.StoreAssociation.xml" />
    <None Include="CpuMeterDesktopBridge_StoreKey.pfx" />
    <Content Include="Images\LargeTile.scale-100.png" />
    <Content Include="Images\LargeTile.scale-125.png" />
    <Content Include="Images\LargeTile.scale-150.png" />
...
    <Content Include="Images\Wide310x150Logo.scale-400.png" />
    <Content Include="..\CPU Meter\bin\Release\CPU Meter.exe">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>


2.wpf添加win10sdk后才可使用StartupTask类.为wpf项目添加引用,引用win10sdk



右键选择给工程Add References,打开文件夹
C:\Program Files (x86)\Windows Kits\10\UnionMetadata


可以看到上图存在16299,17134和17763三个版本,我这里选择了当前比较普及的17134版本。


    仅仅添加这一项是不够的,另一个必选项是
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
完成添加引用的操作后,就可以在AutoLaunchApp工程中使用StartupTask类了。

参考作者:蝴蝶不菲   链接:https://www.imooc.com/article/268529


---

实现商店多语言:

Desktop bridge 实现winstore商店多语言






songshizhao
最初发表2020/3/15 15:31:47 最近更新2020/3/17 1:09:08 2365
为此篇作品打分
10