Could not install Dapper 2.0.4 on .Net 4.6.1 - c#

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.

I tried the following and it worked for me.
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.
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

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

Install .Net Framework SDK version 4.7.1 minimum.
Select installed target as a Target Framework for all Projects in your Solution (in Project properties).
Retarget all packages in all projects executing update-package -reinstall -ignoreDependencies from the Package Manager Console.
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/

Related

Could not install package 'Stripe.net 39.27.0'. You are trying to install this package into a project that targets '

i am installing nuget package strip.net but when installing it give me this error in visoul studio , i did not find any solution plz need your solution
Severity Code Description Project File Line Suppression State
Error Could not install package 'Stripe.net 39.27.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', 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. 0
The problem is that the latest nuget package Stripe.net 39.27.0 does not support your old target framework version 4.5.2. It is designed by the nuget author.
First, see this of Stripe.net 39.27.0: The nuget package supports net framework >=4.6.1 and net standard>=2.0. Since your target framework is 4.5.2 and also net standard 2.0 does not support 4.5.2 but supports >=4.6.1,see this document, so you do not meet either of these conditions.
So the solution is to either downgrade your nuget package or upgrade the target framework version of your project.
Solution
1) downgrade your nuget package, try to install the nuget package Stripe.net 37.35.0 and it supports net framework 4.5.2.
2) upgrade your project's framework version. Right-click on your project-->Properties-->Application--> change Target Framework to 4.6.1. And then you can install the latest nuget package Stripe.net 39.27.0.

Cannot update Microsoft.Extensions.Logging to (2.0) Mono Develop 6.1.4

My packages in my project indicated there was a version update to 2.0 for:
Microsoft.Extensions.Logging
NETStandard.Library
Microsoft.NETCore.Platforms
The only one I cannot get to update is Microsoft.Extensions.Logging
The Error I get is this:
Package 'Microsoft.Extensions.Logging 2.0.0' does not exist in folder '/home/MyUser/UpdatedPon/pon/sbmanager/packages'
Could not install package 'Microsoft.Extensions.Logging 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', 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 have been searching the internet the past few days looking for a solution, but I have not found one as of yet.
Has any one ran into this issue, I am running MonoDevelop 6.1.4
and my MONO version is 5.2.0.215.
Lastly this is a WebForms application.
The Microsoft.Extensions.Logging 2.0.0 NuGet packages has assemblies for .NET Standard 2.0.
A more recent version of NuGet is required for .NET Standard 2.0 to be recognised as a target framework. So you would need to use MonoDevelop 7.1 for this to work. Also your project would need to target .NET 4.6.1 to be able to install the NuGet package.
Alternatively you could try installing the older version Microsoft.Extensions.Logging 1.1.2 which contains .NET Standard 1.1 assemblies which should be recognised by MonoDevelop 6.1.

Farsi.Library 2.7.0 Fails to install

I tried to install Farsi.Library 2.7.0 through the NuGet Package Manager Console.
But following error occurs:
Install-Package : Could not install package 'Farsi.Library 2.7.0'. You
are trying to install this package into a project that targets
'.NETFramework,Version=v4.5.2', 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.
According to his blog entry all versions of this library beyond and including version 2.6 are based on .NET Framework 4.6 - somehow this fixes a few bugs with the persian calendar. This is why the installation fails for you.
Install version 2.5.1.5, the latest version of this library which is based on .NET Framework 2.0, to bypass this.
Or upgrade your project to .NET Framework 4.6 or later.
Install-Package Farsi.Library -Version 2.5.1.5

Set NuGet package target framework

I'm trying to set a target framework for my NuGet package with NuGet Package Explorer. I've created a folder lib/net462/myassembly.dll. I want to prevent the package from being installed on .NET projects targeted lower than version 4.6.2. When I install the package in a .NET 4.5.2 project, no error is thrown and the dll is installed in the project.
How can I prevent my package from being installed in a .NET project targeted lower than version 4.6.2?
See screenshot below:

Targetting a different package version based on build profile

I've got a class library that till today was for .NET 4.5, now I've been asked to port it to .NET 40 but I've got some difficulies. I've followed this approach
and it works for the nuget packages that
but using this approach I get an error when going to Manage Nuget Packages telling
What's the most clean way to target different .NET framework version without loosing nuget package manager?
UPDATE #1
I've this version of nuget package manager
The error message caused by the duplicate packages listed in packages.config file. Because the Manager NuGet Packages window will read the packages.config file to list installed packages in your project and manage them.
For your situation, please check whether the packages in your project could compatible with both of .NET 4.5 and .NET 4.0. If yes, you need not to use two version packages in one project. You just need to change the project .NET Framework through Project -> Properties -> Application -> Target Framework.
If the installed packages version could not compatible with .NET 4.5 and .NET 4.0 at the same time, and you still want to use the Manager NuGet Packages, I suggest you do with below manual operation: Comment out one version of the packages in packages.config file and then open Manager NuGet Packages. After using Manager NuGet Packages, please uncomment the version that commented before.

Categories