MVVM Light程序集与Microsoft.Practices.ServiceLocation冲突

问题描述 投票:0回答:4

我有一个问题,我的WPF应用程序无法使用ClickOnce发布。

该应用程序使用Nuget包MVVM Light 4.1.26.1,Unity 2.1.505.2,CommonServiceLocator 1.0。

问题是,当我发布时,一切都很好,但是当我尝试安装clickonce包时出现这个错误:

无法安装或运行该应用程序。该应用程序要求首先将程序集Microsoft.Practices.ServiceLocation版本1.0.0.0安装到全局程序集缓存(GAC)中。

我做了一些挖掘,发现清单中有两个对该程序集的引用,其中一个被标记为我无法摆脱的先决条件:

<dependency>
    <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
      <assemblyIdentity name="Microsoft.Practices.ServiceLocation" version="1.0.0.0" publicKeyToken="59D6D24383174AC4" language="neutral" processorArchitecture="msil" />
    </dependentAssembly>
  </dependency> 

<dependency>
    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="Microsoft.Practices.ServiceLocation.dll" size="29760">
      <assemblyIdentity name="Microsoft.Practices.ServiceLocation" version="1.0.0.0" publicKeyToken="31BF3856AD364E35" language="neutral" processorArchitecture="msil" />
      <hash>
        <dsig:Transforms>
          <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
        </dsig:Transforms>
        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
        <dsig:DigestValue>eee+a+dQmhpSY/ApLxRipXdEp8UsTaZHXHClBU0Iwyc=</dsig:DigestValue>
      </hash>
    </dependentAssembly>
  </dependency>

我非常确定ClickOnce的问题是由于对该程序集的两个引用具有相同的版本(但请注意不同的公钥标记)。

我创建了一个非常简单的repro如下:

  1. 创建一个新的WPF应用程序
  2. 添加Nuget包MVVM Light
  3. 添加Nuget包Unity(还添加了名为CommonServiceLocator的依赖包)
  4. 构建并发布WPF应用程序
  5. 尝试并安装已发布的MyApp.application clickOnce包....获取上面详述的错误

这是一个repro项目:

skydrive repro project

我有什么想法可以克服这个问题?

mvvm-light
4个回答
1
投票

请再试一次。我刚刚将一个新版本(4.1.27.0)推送到Nuget,这取决于可用的官方CommonServiceLocator包。这应该可以解决您的问题。如果您有更多问题,请务必告诉我。

干杯洛朗


3
投票

它现在是2019年,我遇到了类似的问题,发现这个问题是第一个条目,但发现另一个(更近期的)问题和解决方案让MVVMLight和Microsoft.Practices.ServiceLocation一起工作。

Mvvmlight 5.4.1.1不适用于CommonServiceLocater 2.0.4(这是2019年3月最新的稳定版本)mvvmlight引导它的方式是ViewModelLocator.cs

两件事有效: 要么降级为 CommonServiceLocater 1.3.0 Mvvmlight 5.3.0.0

或更改参考

using Microsoft.Practices.ServiceLocation;    

using CommonServiceLocator;

1
投票

是。 MVVMLight ServiceLocation程序集使用与每个其他公共实现不同的公钥标记。它已经让我的生活成了一段时间的噩梦。我终于不得不撕掉我所有的nuget程序集,现在回到公共目录中的文件引用。我在等劳伦特来解决这个问题。


0
投票

尽管安装了MVVMLight nuget包的4.1.27版本,但我也遇到了这个问题。经过几个小时的挫折,我发现这是因为我安装了MVVMLight工具包(适用于Visual Studio 2012的v.4.1)。一旦我卸载它,我的部署就开始重新运行了。

我以为我会留下这个,以防其他人遇到这种特殊情况。

© www.soinside.com 2019 - 2024. All rights reserved.