4

My winforms solution was working, but when I re-opened it, some of the references were no longer working. Hence I removed all the references in the project including the references to microsoft dlls.

Now I am trying to add back the references.
What should I do first?

I tried using package manager to add Entity Framework, but got an error. 'EntityFramework 6.1.3' already installed. Failed to add reference to 'System.ComponentModel.DataAnnotations'.

Now When I open package manager, and select On Line, Entity Framework is ticked. However when I select Installed Packages it states "No packages are installed in the current solution"

When I try to build I get an error message

Error   1   This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is E:\EShared\devnet10\SBD.Scheduling\\.nuget\NuGet.targets.  E:\EShared\devnet10\SBD.Scheduling\SBD.Scheduling.Core\SBD.Scheduling.Core.csproj   117 5   SBD.Scheduling.Core

I tried adding a reference to System.ComponentModel.DataAnnotations but it shows in the references with a little yellow exclamation mark.

When I double click the reference icon in solution exporer I get the message

The project cannot be viewed in the object browser because it is unavailable or not yet built

After using version control to revert back to my version with EF6.0.2 , I was then able to install 6.0.3 successfully.

I would still like to know what went wrong.

Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • did you try this: http://stackoverflow.com/a/10174457/1845408 – renakre Apr 03 '15 at 03:33
  • Pro Tip: If you _installed_ it with nuget, you need to _uninstall_ it with nuget. Manually editing the references node of your project leaves the packages/projects out of sync. Probably going to need to manually remove reference from `packages.config`. – Brad Christie Apr 03 '15 at 03:43
  • yes, i removed from packages.config and deleted the EF folder within the packages. – Kirsten Apr 03 '15 at 03:45
  • it seems i cant add any reference. I am looking into http://stackoverflow.com/questions/22909506/this-project-references-nuget-packages-that-are-missing-on-this-computer – Kirsten Apr 03 '15 at 03:52
  • 1
    Did you make sure you have the latest version of the Nuget extension on your VS? – Andre Pena Apr 03 '15 at 04:32

2 Answers2

4
  1. Close your Visual studio.

  2. From the Start screen, right-click the Windows PowerShell app tile (or search for it in the search bar).

  3. Click Run as administrator (Very Important).

  4. Run this command: Set-ExecutionPolicy Unrestricted

  5. Now go back to your visual studio and download your Nuget package(s).

  6. Run this command to set it back to secure setting: Set-ExecutionPolicy Restricted

ylerjen
  • 4,109
  • 2
  • 25
  • 43
  • Thanks, I will try this next time I have the problem. I cant remember what I did to work around it at the time.... but Run as administrator sounds familiar and Set-ExecutionPolicy sounds new. – Kirsten Apr 27 '15 at 21:18
3

You can use this command from the Package Manager Console:

Update-Package –reinstall EntityFramework

If you just want to reinstall everything that is defined in packages.config, use this command:

nuget install packages.config

It will also restore the missing packages.

codebased
  • 6,945
  • 9
  • 50
  • 84