sirch sarso
sirch sarso

Reputation: 103

Could not install Dapper 2.0.4 on .Net 4.6.1

I'm trying to install Dapper 2.0.4 via nuget manager as i want to use the latest Dapper.Contrib features It didn't proceed due to the following error:

Could not install package 'Dapper 2.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.

If i install the lower version (1.6), the installation went successful but i can't use the latest Contrib features.

How can i resolve this?

Hoping for your kind help. Thank you.

Upvotes: 5

Views: 9015

Answers (3)

mrNiceGuy
mrNiceGuy

Reputation: 1

Try this instead

  1. Go to "Tools > NuGet Package Manager > NuGet Manager Settings > Package Sources
  2. Once in Package Sources, set name to "Package Source" and Source to "https://www.nuget.org/api/v2/package/Dapper/" then update to save
  3. Install .Net Framework SDK version 4.7.1 minimum.
  4. Select installed target as a Target Framework for all Projects in your Solution (in Project properties).
  5. Retarget all packages in all projects executing update-package -reinstall - ignoreDependencies from the Package Manager Console.
  6. Install Dapper.

That should do it for you.

Upvotes: 0

sri sivani charan
sri sivani charan

Reputation: 409

I tried the following and it worked for me.

  1. Check Target Framework by right-clicking on the project and selecting the Application tab. If the target framework is .NET framework 4.6.1 Install-Package Dapper -Version 2.0.4 works fine.
  2. If the target framework is less than 4.6.1 (In my case another project has target framework 4.5.2) try installing previous versions of Dapper for example:Install-Package Dapper -Version 1.50.2

Upvotes: 3

Megrez7
Megrez7

Reputation: 1457

  1. Install .Net Framework SDK version 4.7.1 minimum.
  2. Select installed target as a Target Framework for all Projects in your Solution (in Project properties).
  3. Retarget all packages in all projects executing update-package -reinstall -ignoreDependencies from the Package Manager Console.
  4. Install Dapper.

UPDATE (from comments):

Dapper needs .NET Standard 2.0. Please retry the whole procedure including re-targeting with .NET Framework 4.7.2 as this is the first fully compliant with. Source: weblog.west-wind.com/posts/2019/Feb/19/

Upvotes: -1

Related Questions