13471

ASP.NET 5: Error with Nuget package in Class library Package

I start playing with VS2015 community version and ASP.NET 5.

I have added a new class library (Package) as a new project into my solution but am unable to install a NuGet package in it. After the restoring, I have a "Reference (Errors - see Error List)".

If i add a basic Library Class (.dll) as a new project into my solution and try to install the same NuGet package, it works beautifully as it used to.

Perhaps, I am misunderstanding how this new class library package works and I am trying to misuse it...

Thanks for your help.

--------------------------------------------------------------EDIT 1----------------------------------------------------------- Project.json: The warning flag in that case is on the EF package: <img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/LAUwV.png" alt="Class Libary package with error on EF">

{ "version": "1.0.0-*", "description": "testFinal Class Library", "authors": [ "SylvainC" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "dependencies": { "System.Collections": "4.0.10-beta-23019", "System.Linq": "4.0.0-beta-23019", "System.Threading": "4.0.10-beta-23019", "System.Runtime": "4.0.10-beta-23019", "Microsoft.CSharp": "4.0.0-beta-23019", "EntityFramework": "6.1.3" }, "frameworks": { "dotnet": { } } }

----------------------------------------------------EDIT 1 bis after update to beta8--------------------------

{ "version": "1.0.0-*", "description": "ClassLibrary5 Class Library", "authors": [ "SylvainC" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "frameworks": { "dnx451": { } }, "dependencies": { "EntityFramework": "6.1.3" } }

--------------------------------------------------------------EDIT 2-----------------------------------------------------------

After upgrading the dnvm (dvnm upgrade), i was able to run the "dnu restore" command but got the following error:

>dnu restore Microsoft .NET Development Utility Clr-x86-1.0.0-beta8-15858 GET https://www.nuget.org/api/v2/ GET https://www.myget.org/F/aspnetmaster/api/v2/ Restoring packages for D:\testFinal\project.json GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection' GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization' GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework' Warning: FindPackagesById: System.Globalization An error occurred while sending the request. Warning: FindPackagesById: System.Globalization An error occurred while sending the request. Warning: FindPackagesById: System.Reflection An error occurred while sending the request. GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection' GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization' Warning: FindPackagesById: System.Reflection An error occurred while sending the request. GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection' Warning: FindPackagesById: EntityFramework An error occurred while sending the request. Warning: FindPackagesById: EntityFramework An error occurred while sending the request. GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework' Warning: FindPackagesById: System.Reflection An error occurred while sending the request. GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection' Warning: FindPackagesById: System.Globalization An error occurred while sending the request. Warning: FindPackagesById: System.Globalization An error occurred while sending the request. GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization' GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization' Warning: FindPackagesById: System.Reflection An error occurred while sending the request. GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection' Warning: FindPackagesById: EntityFramework An error occurred while sending the request. GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework' Warning: FindPackagesById: EntityFramework An error occurred while sending the request. GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework' Error: FindPackagesById: System.Reflection An error occurred while sending the request. ---------- Error: FindPackagesById: System.Globalization An error occurred while sending the request. Error: FindPackagesById: System.Globalization An error occurred while sending the request. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8888 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace ---

---------------------------------------------EDIT 3 with final error and feeds------------------------------

Restore failed An error occurred while sending the request. NuGet Config files used: C:\Users\sylvainc\AppData\Roaming\NuGet\nuget.config Feeds used: https://www.nuget.org/api/v2/ https://www.myget.org/F/aspnetmaster/api/v2/

Sylvain

Answer1:

It seems to be a proxy issue giving me this No connection could be made because the target machine actively refused it 127.0.0.1:8888 error.

Tracking it down with Fiddler, I discovered that after opening Fiddler, the restore process and adding new Nuget packages was working fine. A situation quite similar to this post Why calling API in ASP.NET works only if I have Fiddler open? or here: http://www.telerik.com/blogs/help!-running-fiddler-fixes-my-app-.

I also tried to create a dnx.exe.config into C:\Users\sylvainc\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta8\bin as suggested in http://github.com/aspnet/dnx/issues/451. Unfortunately it seems not to work with the beta8 version.

My first workaround solution was to use the HTTP protocol to access my NuGet packages as suggested here: Visual Studio 2015 - Can't sign in, Use NuGet, etc. behind corporate proxy.

My final solution was to edit the machine.config file as administrator with Notepad+ in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config to get ride of the fiddler default proxy definition and to use the system ones:

<!--<system.net> <defaultProxy enabled="true" useDefaultCredentials="true"> <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false"/> </defaultProxy> </system.net>--> <system.net> <defaultProxy useDefaultCredentials="true" enabled="true"> <proxy usesystemdefault="True"/> </defaultProxy> </system.net>

Now ASP.Net 5 works fine, I even have my intellisense working properly now which was not the case before with the other proxy definition...

Thanks

Sylvain

Answer2:

Be sure you installed the latest tooling for Visual studio. Your project.json seems to be wrong.

Check your nuget feed in visual studio for invalid feed and remove these sources.

Check your active dnx (*)

dnvm list Active Version Runtime Architecture OperatingSystem Alias 1.0.0-beta4 clr x86 win 1.0.0-beta7 clr x64 win 1.0.0-beta7 clr x86 win b7 1.0.0-beta7 coreclr x64 win 1.0.0-beta7 coreclr x86 win 1.0.0-beta8 clr x64 win * 1.0.0-beta8 clr x86 win aa, b8 1.0.0-beta8 coreclr x64 win 1.0.0-beta8 coreclr x86 win 1.0.0-rc1-15838 clr x86 win rc1a 1.0.0-rc1-16031 clr x86 win default 1.0.0-rc1-16031 coreclr x86 win

With the tools->nuget package manager-package manager for solution * Select a package source and test if a package source give any errors * find out in which nuget feed your package is available

At the end of the dnu output there is a list which config and feeds are used

NuGet Config files used: C:\Users\Thom\AppData\Roaming\NuGet\nuget.config Feeds used: https://api.nuget.org/v3-flatcontainer/ https://www.myget.org/F/aspnetrelease/api/v3/flatcontainer/

Use the dnu restore -? to find the source of the problem.

try this dnu restore --no-cache --packages .\packages1

Try a package.json like this

{ "version": "1.0.0-*", "description": "ClassLibrary3 Class Library", "authors": [ "Thom" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "dependencies": { "EntityFramework": "6.1.3" }, "frameworks": { "dnx451": { }, } }

Answer3:

In my case, the package source was pointing to http://packagesource. Changing it to https://www.nuget.org/api/v2/ fixed the probmel

Recommend

  • How do I undo the most recent commits in Git?
  • How Do I Ignore Errors When Deleting Records
  • Where is NuGet.Config file located in Visual Studio 2017 project?
  • Fatal error when updating joomla from 3.1.1 to 3.2.2
  • Where can I store the iOS device token for later use?
  • Swift iOS Cache WKWebView content for offline view
  • What's the difference between Tensor and Variable in Tensorflow
  • Resharper is not runing tests with attribute [Test]
  • Full CoreData uploading (backup) to iCloud Drive and restore if need
  • Restoring specific TensorFlow variables to a specific layer (Restore by name)
  • Android: When a service is killed, how can we persist the service state for later restoration?
  • How to import a Oracle 11g RMAN backupset on a new database server?
  • What's the recommend way of restoring only parts model in distributed tensorflow
  • How to Restore Database in Server's sql server Database?
  • Tensorflow restored weights is not set
  • Move Redshift from Subnet 1 to Subnet 2 within the same VPC
  • Memory profiling tool for Delphi?
  • sigprocmask during signal's execution
  • OSX Installing Rsymphony - linking headers and libs
  • Java: convert floating point binary to floating point decimal
  • GUIDs in DLLs (.Net)
  • ASP.NET 5: Error with Nuget package in Class library Package
  • MVC - Dynamically loading Partial Views
  • How to develop MS CRM kind of application
  • ConfigurationBuilder not working in azure function
  • Unable to play media with vlc ocx
  • Translating C# to PowerShell in InterIMAP
  • Detecting null parameter in preprocessor macro
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • android google indoor map
  • pillow imaging ImportError
  • Problems installing Yesod for Haskell
  • error importing numpy
  • Cross-Platform Protobuf Serialization
  • jquery mobile loadPage not working
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?