Sylvain C.
Sylvain C.

Reputation: 1073

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: 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

Upvotes: 2

Views: 5033

Answers (3)

Xiaoguo Ge
Xiaoguo Ge

Reputation: 2328

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

Upvotes: 0

Sylvain C.
Sylvain C.

Reputation: 1073

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

Upvotes: 4

Thom Kiesewetter
Thom Kiesewetter

Reputation: 7354

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": { },
  }
 }

Upvotes: 0

Related Questions