【问题标题】:Cannot add MVVM Light libraries through NuGet无法通过 NuGet 添加 MVVM Light 库
【发布时间】:2014-04-13 08:31:48
【问题描述】:

我正在尝试通过 NuGet 将 MVVM Light 添加到现有项目,但收到以下错误消息:

Attempting to resolve dependency 'MvvmLightLibs (≥ 4.2.30.0)'.
Attempting to resolve dependency 'CommonServiceLocator (≥ 1.2)'.
Successfully installed 'CommonServiceLocator 1.2'.
Successfully installed 'MvvmLightLibs 4.3.31.1'.
Successfully installed 'MvvmLight 4.2.30.0'.
Successfully uninstalled 'CommonServiceLocator 1.2'.
Install failed. Rolling back...
Could not install package 'CommonServiceLocator 1.2'. You are
trying to install this package into a project that targets
'.NETFramework,Version=v4.0,Profile=Client', but the package
does not contain any assembly references that are compatible
with that framework. For more information, contact the package
author.

我尝试将我的项目重新定位到 .NET Framework 4.0、4.0 客户端配置文件和 4.5。有任何想法吗?两周前我还没有遇到过这个问题。

【问题讨论】:

    标签: nuget mvvm-light


    【解决方案1】:

    今天遇到了同样的问题。首先尝试在您的 Visual Studio 插件中安装最新版本的 Nuget!

    【讨论】:

    • 这为我解决了这个问题。要安装最新的 nuget,请进入 Visual Studio 工具菜单。转到扩展和更新。转到已安装的包并查找 NuGet。单击更新以获取最新的 NuGet 功能。重新启动 Visual Studio。转到 PM 控制台并输入:install-package MVVMLightLibs
    • 是的,更新 NuGet 包管理器解决了我同样的问题
    【解决方案2】:

    我能够在以 4.5 为目标并使用 Nuget 进行“仅限 MVVM Light Libraries”时进行安装

    首先安装https://www.nuget.org/packages/CommonServiceLocator/1.2.0 会为您避免这个问题吗?

    【讨论】:

    • 谢谢,我做了同样的事情并且能够安装 MVVMLight,但是我确实需要 CommonServiceLocator,因为它增加了对 Autofac 的支持,这是我首选的 IoC 容器。单独安装 CommonServiceLocator 仍然返回相同的错误消息。
    • 它是否与 Autofac 冲突,并且无法卸载 CommonServiceLocator 的 Autofac 版本?这很蹩脚,但有时我会求助于创建一个有问题的部分工作的新项目,然后手动复制旧代码。
    【解决方案3】:

    我遇到了同样的问题。将 Visual Studio 2012 更新为 Update 4,再次尝试,它运行良好。祝你好运!

    【讨论】:

      【解决方案4】:

      听起来您的项目是针对 .NET 4.0 的,而您正在安装与目标版本不兼容的库。

      请找到合适的库版本并安装它们

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-04-19
        • 1970-01-01
        • 2012-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-10
        相关资源
        最近更新 更多