1
votes

I created a new class library, accepting the default settings, and added a couple of packages via nuget (Sendgrid, System.Data.SqlClient below).

enter image description here

There's also a project.json:

{
  "version": "1.0.0-*",
  "description": "ClassLibrary1 Class Library",
  "authors": [ "adamwhitehouse" ],
  "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",
    "System.Data.SqlClient": "4.1.0",
    "Sendgrid": "8.0.3"
  },

  "frameworks": {
    "dotnet": { }
  }
}

When I try and reference these in the generated Class1.cs file, it's as if they don't exist, although they appear to be referenced exactly as the others (System.Collections, System.Threading, etc).

enter image description here

I've done absolutely nothing besides what I've outlined here. I'm sure it's something stupid, but I haven't created a project in Visual Studio in a while and it seems things have changed. What am I missing?

2
What version of Visual studio and what king of project it is ? windows class library, core,... ? - Mathieu
it's all in the question, vs 2015 class library project - aw04
Sorry but I can't reproduced that kind of project structure either in windows class library neitehr in core class library. Your references are in beta, I don't see how to do that - Mathieu
Ah.. I think I used the wrong project type, hold on - aw04
I can't seem to find an official announcement, but didn't Visual Studio drop support for the project.json project file and call it a failed experiment? I create a new project in VS2015 with all the latest updates, and I get the old traditional csproj file. - Joe Enos

2 Answers

0
votes

try running Update-Package -reinstall in the nuget console, I fixed a similar issue by adding the -reinstall part

0
votes

For whatever reason, my new project dialog defaulted to Class Library (Package), which is apparently not what I wanted.

When I went back and selected the correct project type, everything works as expected.

enter image description here