mrogunlana
mrogunlana

Reputation: 847

Is it possible to install Autofac 4.6.2 in a Xamarin.Forms (PCL) application?

When I install the latest Autofac (4.6.2) nuget in Visual Studio 2017, I get the following exception:

Could not install package 'System.Runtime.InteropServices.RuntimeInformation 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', 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.

I poked around on the Xamarin forms and found: https://forums.xamarin.com/discussion/90997/autofac-installation-issue and the answer I found there was in reference to targeting .NET standard. But, I'm targeting .NET 4.5.

Help?

Upvotes: 1

Views: 421

Answers (1)

Evk
Evk

Reputation: 101543

That seems to be some bug in nuget, discussion of which you can find here. Profile you use (111) is compatible with Autofac 4.6.2, because Autofac of this version has net standard 1.1 version, and given profile does support .net standard 1.1. To resolve that issue, add project.json file with the following content to your project (build action can be None, and copy to output Do Not Copy):

{
  "dependencies": {
    "Autofac": "4.6.2"
  },
  "frameworks": {
    ".NETPortable,Version=v4.5,Profile=Profile111": {}
  },
  "supports": {}
}

Then close and reopen solution. After that, installing Autofac should be successful.

Upvotes: 0

Related Questions