Unity installation is giving error

Asked

Viewed 1,052 times

1

I went to install Unity for DI and the Nuget is giving an error, I did not understand, it seems to me that it points to the Newtonsoft, see the error below:

Install-Package : An error occurred while retrieving package Metadata for 'Newtonsoft.Json.10. 0.2' from source 'C: sites meu_projeto_webapi Packages'. At line:1 char:1 + Install-Package Unity + ~~~~~~~~~~~~~~~~~~~~~~~~~ + Categoryinfo : Notspecified: (:) [Install-Package], Exception + Fullyqualifiederrorid : Nugetcmdletunhandledexception,Nuget.PackageManagement.Powershellcmdlets.Installpackagecommand

I tried to remove it like this: PM> Unistall-Package Newtonsoft.Json RemoveDependencies and gives an error similar to the above, but with this message:

'Removedependencies' is not found.

2 answers

1

I recently had the same problem with Newtonsoft. I was able to solve it by updating.

Update-Package Newtonsoft.Json
  • I have already done this and I still can’t install Unity. I will remove Newtonsoft and try to install the other package and finally Newtonsoft.Json.

  • After you have updated the package, it returned you the same error?

  • By Nuget I can’t remove. I did that: Uninstall-Package Newtonsoft.Json and gives error. There is another way for me to uninstall?

  • No update, he updated, at least no error.

  • It has some dependencies, you have to uninstall them.

  • Yeah, I did that: Uninstall-Package Newtonsoft.Json RemoveDependencies, unless the line above is wrong, it didn’t work either

  • See if this solution solves your problem. https://stackoverflow.com/a/32794295/4312593

Show 2 more comments

0

This error is not related to Unity, exactly. For some reason, your Visual Studio could not connect to Nuget.

Try running the following command before trying to install Unity again in the Package Manager Console:

PM> Update-Package

I don’t think it’s a good idea to remove JSON.NET, but anyway, the correct command is:

PM> Unistall-Package Newtonsoft.Json -RemoveDependencies
  • So, I’ve done it with and without hyphen and gives the error that I put in the original post(I edited). With -force gives me this error: Object reference not set to an instance of an object.. I will update and try to reinstall Unity.

  • 1

    I can’t even uninstall and install Unity, now I’m in the garden anyway.

  • Yes, but do not remove JSON.NET. It is used in all operations. I only added that part in the answer to knowledge question.

  • I know, the intention would be to uninstall, install the two other packages and then finally install Newton. That’s the idea, because I need it for Json communication and so on...

  • While you’re at it, why don’t you use the Simpleinjector instead of Unity?

  • I can try, is that in the example the author installed this package, but I can replace yes, it would be a plus in the course.

  • Gypsy, gave the same mistake as Unity, ie referring to Newton.

  • So it is not Unity or Simple Injector error. It is Nuget error. It is possible to start a new project?

  • I restarted VS2015 and will test now, otherwise I start another test project and try to install everything again.

  • I created a Webapi test project, I saw that Newtonsoft.Json was already installed and I was able to install Unity in this new one, but in the previous one, I restarted VS2015 and still could not install. Makes the same mistake.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.