ClickOnce 需要 System.Windows.Interactivity 版本 4.5.0.0

ClickOnce requires System.Windows.Interactivity Version 4.5.0.0

我正在使用 Visual Studio 2015 发布 WPF 应用程序。发布后,当我单击 .application 文件时,它会抛出此错误:

Unable to install or run the application. The application requires that assembly System.Windows.Interactivity Version 4.5.0.0 be installed in the global assembly cache (GAC) first.

我的应用中 System.Windows.Interactivity 的版本是 4.0.0.0。那么为什么它会要求 4.5.0.0?我什至在网上找不到那个版本。

基于 this question,我更新了我的 app.config 以使用此功能,但无济于事:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.5.0.0" />
  </dependentAssembly>
</assemblyBinding>

在 Visual Studio 的错误列表选项卡中,它有以下警告:

Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

我做错了什么?谢谢。

显然,MVVM Light Toolkit 在项目中安装了 System.Windows.Interactivity 的 4.5 版本,这与 4.0 版本存在冲突。解决方案:

  1. 展开项目引用。
  2. 找到System.Windows.Interactivity.
  3. 右键单击它并选择删除。
  4. 右键单击引用并选择添加引用。
  5. 在“程序集”>“扩展”下,选中 System.Windows.Interactivity 版本 4.5.0.0 的复选框。
  6. 单击“确定”关闭引用。

现在重新发布,安装程序运行正常。作为上述冲突原因研究的一部分,我 enabled diagnostic output 进行构建,生成了详细的日志。在大约第 2,000 行,它包括:

Unified Dependency "System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". (TaskId:13)
1>      Using this version instead of original version "4.0.0.0" in "C:\Users\myUserName\Documents\Visual Studio 2015\Projects\MyProject\packages\Blend.Interctivity.WPF.v4.0.1.0.3\lib\net40\Microsoft.Expression.Interactions.dll" because of a binding redirect entry in the file "App.config". (TaskId:13)
1>      Resolved file path is "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45\System.Windows.Interactivity.dll". (TaskId:13)
1>      Reference found at search path location "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45". (TaskId:13)
1>          For SearchPath "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45". (TaskId:13)
1>          Considered "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45\System.Windows.Interactivity.winmd", but it didn't exist. (TaskId:13)
1>      Required by "GalaSoft.MvvmLight.Platform, Version=5.2.0.37226, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL". (TaskId:13)
1>      Required by "Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". (TaskId:13)
1>      This reference is not "CopyLocal" because it conflicted with another reference with the same name and lost the conflict. (TaskId:13)
1>      The ImageRuntimeVersion for this reference is "v4.0.30319". (TaskId:13)