简体   繁体   中英

The type or namespace 'system' could not be found in .Net Core app

Trying to launch my .Net Core app in the browser results in numerous errors . The project builds fine in VS 2015. I tried cleaning the solution and running dotnet restore, neither solved the problem. There are no missing using statements anywhere in the project. All the dependencies are updated.

global.json

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}

project.json

{
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Hosting": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.DependencyInjection": "1.0.0",
    "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "commands": {
    "web": "Microsoft.AspNetCore.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "net451": {
      "dependencies": {
        "Microsoft.AspNet.Web.Optimization": "1.1.3"
      }
    },
    "netcoreapp1.0": {
      "imports": [ "dnxcore50", "portable-net45+win8" ],
      "dependencies": {
        "Microsoft.NETCore": {
          "type": "platform",
          "version": "5.0.0"
        }
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishOptions": [
    "**.user",
    "**.vspscc"
  ]

}

I've tried "reinstalling" Nuget Package Manager as suggested here , which I understood to mean removing and then re-adding the nuget.org package source in Visual Studio via Tools > Nuget Package Manager > Package Manager Settings > Nuget Package Manager > Package Sources . This also did not prove to be a solution for me.

How is it that I'm unable to launch in the browser despite having a successful build? Please let me know if more information is needed, I'm not a .Net expert by any means.

I am not sure where you found this:

"Microsoft.NETCore": {
      "type": "platform",
      "version": "5.0.0"
}

but most likely you want:

 "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
 }

Also commands is no longer a thing you can remove it. You need to use tools instead.

I got the same issue with a brand new .net core project on visual studio CE 2017.

I solved this by using Tools > NuGet Package Manager > Manage NuGet packages for solution, then updated Microsoft.ApplicationInsights.ASPNetCore to the latest stable version there and magically it all started working. Not sure whether it would help in this instance, but it appears that some aspects of the .netCore SDK were not present on my VS2017.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM