Unable to install the System.Data.SqlClient - c#

I am trying to create Web API that will connect to the SQL server and run the stored procedure. I wanted to install the System.Data.SqlClient in to the project so I can give the connection details. But when tried to install that through the Nuget Manager it throws error like
Install failed. Rolling back...
Could not install package 'System.Data.SqlClient 4.3.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.
How can I install them or is there any other way of giving the connectionStrings in web.config

I could solve this problem with a little workaround for Xamarin PCL:
Change your PCL target to .NetStandard. You can do it in the PCL project properties.
Create a new .NetStandard ClassLibrary project.
Add the System.Data.SqlClient and your code
Reference the ClassLibrary project dll to the PCL project
With this library you can use the SqlClient.
In your case with asp.net: Perhaps, you can try to create a .NetFramework ClassLibrary and follow the steps above.
I hope it will help you!

Related

Having trouble while Installing a Nuget package(WIndows.winMD)

Getting error while trying to install a Nuget Package
I'm trying to install a pakage and get the following error:
NuGet\Install-Package Microsoft.Windows.WinMD -Version 1.0.210629.2'
NuGet\Install-Package : Could not install package 'Microsoft.Windows.WinMD 1.0.210629.2'. You
are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2',
but the package does not contain any assembly references or content files that are compatible
with that framework.
Please help
Do I understand correctly that you want to write a .net wrapper over a C++?
If so, this is nuget package does not contain dll files. Most likely you need to build the C++ library first and add build result as content in your project.
This nuget package framework is tagged with native.
nuget: Microsoft.Windows.WinMD - Frameworks
The native framework tag is for C++ projects.
DevBlogs: Support for Native Projects
Conclusion: This package can not be consumed or used by any C# project.
However, in the nuget used-by tab of that package is a reference to a C++ github project that uses this package and is described as
C# language projection for the Windows Runtime
You may have a look at that.

Use nuget package instead of project reference Visual studio

We have a solution with 7 to 8 different projects including class libraries and mvc apps. We are using .net 4.6.2 and netstandard 2.0.
We are trying to convert class libraries to nuget packages and instead of referencing the projects directly in our web apps, use nuget packages. We have created the packages and added them in packages.config and the packages are getting installed perfectly fine.
Now, when I remove previous reference and add a new reference and point it to the nuget package, my web apps doesn't work and give assembly not found error.
I think I'm not adding the reference correctly , and need help on this.
If you are using NuGet packages now then you would install the package into each project which needs the assemblies and NuGet will add the references for you. You don't add the references by adding them from the packages directory.
E.g. Install-Package MyPackage MyProject

EMGU error when trying to install Emgu.CV.runtime.windows VS 2019 winforms, framework 4.8

I am trying to install EMGU using Nuget. I am using Framework 4.8. WinForms. I'm able to install Emgu.CV but when I try installing Emgu.CV.runtime.windows I get an error saying:
"Could not install package 'Emgu.runtime.windows.msvc.rt.x64 19.28.29336'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', 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.
One solution on stackoverflow (Emgu error when trying to install emgu.CV.runtime.windows in VC# 2017) says that "the solution is migrating from package.config to package references" but it didn't work in my case. When I changed migrating I get an error when installing Emgu.CV too. The error is "Unable to find fallback package folder 'C:\Microsoft\Xamarin\NuGet'."
After these I tried manually installing Emgu.runtime and copying dll files but I got a problem related to cvextern.dll. It says that the file is not accessible. I tried registering it rgsvr32 it didn't work. So working manually didn't help either.
How am I supposed to install EMGU.
.netFramework version is not compatible with the package that you are trying to install.
1-Uninstall the packages completely from your project. 2-downgrade
your project's .netFramework version from Properties of the project
3-Reinstall the packages.

Telerik UI for UWP NuGet install not working

I am trying to download the Telerik UI for UMP NuGet package using the NuGet Package Manager (I have also tried the console) and I get the following error:
Could not install package 'Telerik.UI.for.UniversalWindowsPlatform 1.0.1.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.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.
I have tried changing my .NETFramework version to 4.6.1 as well but it did not work. Is there something I am missing here? It shouldn't be this hard to add a NuGet package, yet here I am... Thank you in advance!
Telerik.UI NuGet spec does not support .NET. It only supports Windows Universal.

How to add System.Data.SqlClient nuget package into .Net Portable (PCL)4.5 profile

I am writing a crossplatform (iOS and android) Xamarin app and I need a sql connection to my database. I found out that I need System.Data.SqlClient to achieve this. But when I try to add System.Data.SqlClient to my core project I get:
Could not install package 'System.Data.SqlClient 4.4.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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 get that apparently this .NETPortable version is compatible, but what is the solution to this? There must be a way to access a SQL database. Also I found that other posts asked to add System.Data first, but this package doesn't even show up in nuget.
In case that you change your pcl project into .NET Standard you should be able to install this nuget package.
Follow this awesome snack pack!
In Visual Studio Preview there is template to create xamarin project using .netstandard. I can confirm that it works.

Categories

Resources