我开始时很新鲜
dotnet new mvc -o .
dotnet restore
打开 Controllers/HomeController.cs
我在同一个项目中看到有关对另一个.cs文件的引用的错误...
The type or namespace name 'Models' does not exist
in the namespace 'server' (are you missing an assembly
reference?) [my-project]
我不确定问题是什么...相对较新的.Net Core和通过VS Code使用.Net .
$ dotnet --version
2.1.201
~ / Controllers / HomeController.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using server.Models;
namespace server.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
~ / Models / ErrorViewModel.cs
using System;
namespace server.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
- 更新:似乎是omniview服务的一个问题,并且我使用dotnet代码打开了我的
server/
目录的父目录 .