分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

Click Once 和 .NET Standard 兼容性问题

发布时间:2023-09-06 02:03责任编辑:彭小芳关键词:.NET

Click Once 和 .NET Standard 兼容性问题

最近使用Click Once打包使用.NET Standard库的WPF应用时,出现一些无法加载库文件的异常,例如:

Unable to initialize the application (Could not load file or assembly ‘System.Runtime, Version=4.1.1.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a‘ or one of its dependencies. The System cannot find the file specified.

这是一个Bug,https://github.com/dotnet/standard/issues/529

关于.NET Standard lib引用说明的文章:https://andrewlock.net/what-is-the-netstandard-library-metapackage/

微软给出了一个Workaround:

在***.csproj中添加如下代码,即可解决

<ItemGroup> ???<PublishFile Include="netfx.force.conflicts"> ?????<Visible>False</Visible> ?????<PublishState>Exclude</PublishState> ?????<IncludeHash>True</IncludeHash> ?????<FileType>Assembly</FileType> ???</PublishFile> ?</ItemGroup> ?<Target Name="FixClickOnceDependencies" BeforeTargets="_DeploymentComputeClickOnceManifestInfo"> ???<ItemGroup> ?????<_noCopyRefs Include="@(ReferencePath)" Condition="‘%(ReferencePath.Private)‘ == ‘false‘" /> ?????<_noCopyRefsByFileName Include="@(_noCopyRefs->‘%(FileName)‘)"> ???????<OriginalItem>%(Identity)</OriginalItem> ?????</_noCopyRefsByFileName> ?????<_libByFileName Include="@(ReferenceCopyLocalPaths->‘%(FileName)‘)"> ???????<OriginalItem>%(Identity)</OriginalItem> ?????</_libByFileName> ?????<_overlappingRefByFileName Include="@(_noCopyRefsByFileName)" Condition="‘@(_noCopyRefsByFileName)‘ == ‘@(_libByFileName)‘ AND ‘%(Identity)‘ != ‘‘" /> ?????<_overlappingLibByFileName Include="@(_libByFileName)" Condition="‘@(_noCopyRefsByFileName)‘ == ‘@(_libByFileName)‘ AND ‘%(Identity)‘ != ‘‘" /> ?????<_overlappingRef Include="@(_overlappingRefByFileName->‘%(OriginalItem)‘)" /> ?????<_overlappingLib Include="@(_overlappingLibByFileName->‘%(OriginalItem)‘)" /> ???</ItemGroup> ???<ItemGroup Condition="‘@(_overlappingRef)‘ != ‘‘"> ?????<ReferencePath Remove="@(_overlappingRef)" /> ?????<ReferencePath Include="@(_overlappingLib)"> ???????<Private>True</Private> ?????</ReferencePath> ???</ItemGroup> ?</Target>

Click Once 和 .NET Standard 兼容性问题

原文地址:https://www.cnblogs.com/devin_zhou/p/9278858.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved