我有一个ASP核心应用程序。它构建和运行没有任何问题,但Visual Studio显示了很多错误:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<p><strong>Message:</strong> <?!=message?></p>
</body>
</html>
public List<EmployementRequest> requestsGrid_GetData()
{
var ukn = new UKN_DBNAMEEntities();
var query = (from x in ukn.EmployementRequests
join y in ukn.EmployeeCourses on x.PKEmploymentRequest equals y.FKEmployementRequest
join z in ukn.EmployeeLanguages on x.PKEmploymentRequest equals z.FKEmploymentRequest
join w in ukn.EmployeeSkills on x.PKEmploymentRequest equals w.FKEmploymentRequest
select x).ToList();
return query.ToList();
}
文件是默认文件:
| Severity | Code | Description | Project File |
|-----------|----------|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| Error | CS0234 | The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) | 1_Views_Shared__Layout.cshtml |
| Error | CS0234 | The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) | 1_Views_Shared__Layout.cshtml |
| Error | CS0234 | The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) | 1_Views_Shared__Layout.cshtml |
| Error | CS0234 | The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) | 1_Views_Shared__Layout.cshtml |
| Error | CS0234 | The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) | 1_Views_Shared__Layout.cshtml |
| Error | CS0115 | '_Page_Views_Shared__Layout_cshtml.Execute()': no suitable method found to override | 1_Views_Shared__Layout.cshtml |
| Error | CS0103 | The name 'Context' does not exist in the current context | 1_Views_Shared__Layout.cshtml |
| Error | CS0103 | The name 'ViewData' does not exist in the current context | 1_Views_Shared__Layout.cshtml |
关于这个项目的唯一想法不同是它是从控制台应用程序构建的,而不是通过Web模板构建的。
我有以下包装参考:
_Layout.cshtml
答案 0 :(得分:0)
在我看来,通常是Visual Studio无法加载基本的require程序包,例如system
A)尝试清理项目文件夹上的dotnet restore
B)如果不起作用,请清理nuget缓存文件夹,然后再次运行
C)关闭Visual Studio,然后重新启动并再次清洁。也有可能您的僵尸进程仍在运行,并且不允许Visual Studio访问其临时文件夹。
D)将项目复制到新路径(如果可能,则使用git clone)并复制到新的dotnet restore
我什至在Ride中也遇到了这个错误,而以上四个错误帮助我摆脱了这个错误。
希望对您有所帮助 干杯