Visual Studio still referring to packages I already uninstalled - c#

I'm still very new to Visual Studio and C#, and I recently encountered a problem:
I migrated packages.config to PackageReference, then rolled that action back (because it didn't work with WindowsAPICodePack), reinstalled all NuGet packages with Package Manager Console, then removed all packages manually with Package Manager to start all over again, but the code
using Microsoft.WindowsAPICodePack;
still somehow refers to non-existing package. How to fix that?
References
NuGet packages installed

Related

Why can't I use CSharpCodeProvider?

I'm trying to use Microsoft.CSharp to run C# files but I get two errors:
the errors
I'm using visual studio and unity. I used the NuGet package manager to install Microsoft.CSharp, System.CodeDom, and System.CodeDom.Compiler. I'm using all of them at the top of the file.
I don't really know anything about packages and I've never had to install one; I would just put "using packagename" at the top of my code and it worked, so I'm sorry if this is a simple fix.
I tried reinstalling all the packages and nothing changed.
I tried closing and reopening visual studio and nothing changed.
When I installed the NuGet packages it created a packages folder, app.config, and packages.config. I tried uninstalling the packages, deleting the folder and the configs, and then reinstalling the packages. It recreated the folder and configs and nothing changed.
I tried including the packages folder in the project and nothing changed.
I have other (working) packages that I didn't have to install so maybe I need to somehow install the new packages wherever those pre-existing packages are located. But idk how to do that or if it would even help.

Can't access installed Nuget Package

I've got a NuGet package installed, OpenCvSharp4.Windows, but for some reason when I try to use it in my code it is not recognized. I have other C# projects that have it installed the same way and it works fine.
Does anyone know why the package isn't being recognized?
delete obj and bin
rebuild
if problem remains, reinstall Opencvsharp4.Windows, and rebuild
When I tried to test/reproduce this issue on my side, I clicked to install OpenCvSharp4.Windows NuGet package. The installation was automatic and after the process finished installing, I saw that there are several other related NuGet packages installed as well, such as OpenCvSharp4, OpenCvSharp4.runtime.win and OpenCvSharp4.WpfExtensions. It seems OpenCvSharp4.Windows depends on these NuGet packages.
Checked the screenshot you shared, it seems only OpenCvSharp4.Windows NuGet package was installed. Could you please elaborate how you install this OpenCvSharp4.Windows NuGet package?
Suggestion
Please try to install other three NuGet packages which I mentioned above manually and reopen your project to see if it works this time.

NuGet package install fails "Package restore failed. Rolling back package changes for <xamarin.android>"

Installing any package fails with this error, updating packages also creates this error. Clearing the NuGet cache files causes this error to change to "access to the path mono.cecil.dll is denied" when trying to install "Xamarin.GooglePlayServices.Ads". Restarting visual studio causes the package restore error to come back.
Versions:
OS: win 10
Visual Studio Information:https://pastebin.com/vnuyZMWk
Xamarin.Forms Project:
Target framework: .NET 2.0
Xamarin.Android project:
Minimum Android Version: 5.0 (API Level 21)
Target Android Version: Use Compile Using SDK version (8.0)
Well after some trial and error I have the solution.
Visual Studio:
Update visual studio https://pastebin.com/GkEeRqg3
Updates Xamarin.Forms and NuGet
Repair visual studio from the "Visual Studio installer"
This Fixes the access denied to *.dll error
Xamarin.Android project:
Set Target Android Version: 8.1 API 27
This makes the packages the require monoandroid81 happy.
Cleaning house
Delete the folder C:\Users\<Your_Name>\AppData\Local\Xamarin`
Not sure if this was necessary but I am documenting anything I did so others can replicate the solution.
Fixing NuGet
Right-click <Project_name>.android --> Set as startup project.
Tools --> NuGet Package Manager --> Package Manager Console
In the console CLI run Update-Package -Reinstall
Why did this happen?
One way or another some of the NuGet packages used in Xamarin.Android used monoandroid81. Even though my solution was set to use 80 some NuGet packages installed were only compatible with 81. This was shown in the NuGet Console.
Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports:
monoandroid81 (MonoAndroid,Version=v8.1)
I faced the same error when I was trying to update the libraries one by one. Then I tried selecting all required libraries and clicked the Update button bellow the search box and it works. I have to tell that these libraries had dependencies between each other.
Here's an example:

Visual Studio NuGet Cannot Restore Packages

I have a large project that has about a dozen dependencies. I have tried to install them all but ran into an error from VS. I am using Visual Studio 2015
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
Now I have a solution which I can use that is by the same name as this package, but VS refuses to let me updates, remove, or change ANYTHING related to these packages and asks that I restore the packages. I am entirely lost here friends, what should I do?
P.S. the two sources I am using for my package sources are:
https://www.nuget.org/api/v2/
https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
The same error occurs for Lucene.Net.Contrib, pstsdk.net, and various packages.
One thing to check for is if your project is built on a version of the NET framework that is less than or equal to the target framework the package has.
If your project is a NET 4.5 based project, but the nuget package has a NET 4.5.2... then the package manager will error out.
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
When I use the packages sources which you provided, I found that only two versions (4.8.0 & 4.9.0) of package"Lucene.Net.Core" not have the version '3.0.3.1'.
Pay Attention:
I noticed that the author of this package have updated this package at March 11, 2017(3/11/2017), and only release the version 4.8.0 & 4.9.0. So this must be the reason for NuGet restore failed.
Besides, you said:
I have a solution which I can use that is by the same name as this
package, but VS refuses to let me updates, remove, or change ANYTHING
related to these packages
If you want to remove those error packages, you can try to use below command to force uninstall those packages:
Uninstall-Package Lucene.Net.Core -Force
Or you can delete this package from the package folder and delete the package list from the package.config.
Then install the correct version of the packages.
Although I was not able to get any of the posted answers to work, I ended up removing the project entirely and reinstalling VS, my project, and its dependencies. This ended up working.
Another thing to check is that the package manager configuration settings in visual studio list the public nuget feed (and if the feed is enabled too).

Nuget Packages are missing in Visual Studio

I have been using xamarin studio, it works fine when I download a sample project from mvvmcross. It compiles and deploys the device perfectly.
But when I open the project in the visual studio, there are a lot of missing packages for some reasons. Is there a way of handling ? I am using Nuget 2.8 in Visual studio 2013
When I open Nuget as follows, there is a button to restore the missing packages. I clicked on it.
Then it is attempting to download the missing packages, and then it realizes there are dependencies as follows:
Then I am attempting to download the dependency manually as follows but it shows the packages has already downloaded but I am still seeing the missing packages in the solution, nothing is affected.
Therefore I am getting hundreds of errors as follows:
When I take a look at the property of missing packages, I see as follows
You should update your NuGet Package Manager extension in Visual Studio and then try restoring the packages again.
The restore error MvvmCross.Binding already has a dependency defined for MvvmCross.Core is caused by an old version of the NuGet package manager extension not recognising the newer target frameworks that the MvvmCross.Binding NuGet package is using in its group dependencies. This bug has been fixed in a newer version of the NuGet Package Manager.
If you search for the 'already has a dependency defined' error message you will find several cases of this, such as this StackOverflow question, for example:
Can not install NuGet package
Right click on the solution in solution explorer and choose 'restore nuget packages'

Categories