【问题标题】:What PCL Profiles does Autofac 4 support?Autofac 4 支持哪些 PCL 配置文件?
【发布时间】:2016-11-05 15:01:38
【问题描述】:

我们在我们的 PCL (Profile259) 中使用 Autofac 3.5.2,Nuget 告诉我们版本 4.1 可用,但是当我们尝试更新它时,Nuget 失败并显示以下消息:

“您正在尝试将此包安装到针对“portable-net45+win+wpa81+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10”的项目中,但该包不包含任何程序集引用或与该框架兼容的内容文件。有关更多信息,请联系包作者。

有没有人能够让 Autofac 4.1 在任何 PCL 配置文件中工作?

谢谢! -汤姆 B.

【问题讨论】:

    标签: autofac


    【解决方案1】:

    Autofac 4 是使用 netstandard target framework 发布的,它是新 .NET Core 平台的一部分。 netstandard 的重点是用更容易理解的东西替换无数且稍微令人困惑的 PCL 目标。

    Autofac 4 支持netstandard1.1 The documentation on the netstandard TFM ("target framework moniker") explains the compatibility of that. 简而言之:

    • .NET 4.5+ (net45)
    • 单声道/Xamarin 平台
    • 通用 Windows 平台 10 (uap10.0)
    • Windows 8.0 (win8.0)
    • Windows Phone 8.1 (wpa8.1)

    它确实支持 Windows Phone Silverlight (wp8.0) - 以 netstandard1.0 结尾。

    netstandard1.1 与这些 PCL 配置文件兼容(也根据文档):

    • 个人资料7
    • 个人资料32
    • 个人资料44
    • 个人资料111
    • 个人资料151

    它与 Profile259 不兼容 - 那是 netstandard1.0。不兼容的是 Windows Phone Silverlight 目标,Autofac 4 已弃用且不再支持该目标。

    【讨论】:

    • 感谢您的详尽解释!由于 .NET Core (github.com/dotnet/corefx/issues/10445) 中的一个错误以及 XS 使用 Nuget 2 的事实,现在似乎无法将 netstandard1.1 与 Xamarin Studio 一起使用,但很高兴知道我们应该理论上至少可以在未来某个时候更新到 Autofac 4!
    • 在 Profile111 上失败并显示“无法安装包 'System.Runtime.InteropServices.RuntimeInformation 4.0.0'。您正在尝试将此包安装到以 '.NETPortable,Version=v4 为目标的项目中” .5,Profile=Profile111',但包不包含任何与该框架兼容的程序集引用或内容文件。有关详细信息,请联系包作者。不是 Autofac 本身,而是它的依赖项之一。
    【解决方案2】:

    解决方法:

    在您的项目中添加project.json

    {
      "dependencies": {
        "Autofac": "4.2.0",
        // your other dependencies here
      },
      "frameworks": {
        ".NETPortable,Version=v4.5,Profile=Profile111": {}
      },
      "supports": ""
    }
    

    关闭并重新打开项目(可能还有 Xamarin Studio)。我还将 Nuget v3 提要添加到 Xamarin Studio(我刚刚列出了第 2 版),但我不确定这是否有帮助。大致可以关注this blog post

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-19
      • 2010-10-24
      • 2019-04-08
      • 1970-01-01
      相关资源
      最近更新 更多