What PCL Profiles does Autofac 4 support?

时间:2016-08-31 18:51:56

标签: autofac

We're using Autofac 3.5.2 in a PCL of ours (Profile259) and Nuget tells us that version 4.1 is available, but when we attempt to update it Nuget fails with the message:

"You are trying to install this package into a project that targets 'portable-net45+win+wpa81+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

Has anyone been able to get Autofac 4.1 working in any PCL profile?

Thanks! -Tom B.

2 个答案:

答案 0 :(得分:5)

Autofac 4是使用netstandard target framework发布的,The documentation on the netstandard TFM ("target framework moniker") explains the compatibility of that.是新的.NET Core平台的一部分。 netstandard的目的是用更易于理解的东西取代无数且略有混乱的PCL目标。

Autofac 4支持netstandard1.1 left to right简而言之:

  • .NET 4.5+(net45
  • Mono / 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配置文件(也是根据文档)兼容:

  • Profile7
  • Profile32
  • Profile44
  • Profile111
  • Profile151

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

答案 1 :(得分:0)

解决方法:

为您的项目添加project.json

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

关闭并重新打开项目(可能还有Xamarin Studio)。我还在Xamarin Studio中添加了Nuget v3 feed(我刚刚列出了版本2),但我不确定这是否有帮助。您可以粗略地关注this blog post