Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IntelliSense抱怨Microsoft.AspNetCore软件包丢失,尽管存在_C#_Asp.net Core_Blazor - Fatal编程技术网

C# IntelliSense抱怨Microsoft.AspNetCore软件包丢失,尽管存在

C# IntelliSense抱怨Microsoft.AspNetCore软件包丢失,尽管存在,c#,asp.net-core,blazor,C#,Asp.net Core,Blazor,在我的Blazor应用程序中,在客户端,IntelliSense抱怨很多Microsoft.AspNetCore包,尽管项目编译和运行良好 我得到很多东西,比如 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) The type or namespace name 'Razor' d

在我的Blazor应用程序中,在客户端,IntelliSense抱怨很多Microsoft.AspNetCore包,尽管项目编译和运行良好

我得到很多东西,比如

The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)    
The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)  
...
@inject HttpClient Http
诸如此类

The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)    
The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)  
...
@inject HttpClient Http
也用红色波浪线划线

该项目构建和运行完美

这里怎么了

后续行动1 因为我被要求提供所有版本:

  • Visual Studio 2019,16.0.2
  • Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview4-19216-03
  • 在我的项目中:
关闭VS

删除.vs文件夹或.suo文件


重新启动VS

您需要Visual Studio预览版本16.1或更高版本才能使用3.0.0-preview4 Blazor

如果仅此一点没有帮助,请确认您的客户端项目中没有任何
.cshtml
文件-它们自3.0.0-preview4以来都有
.razor
扩展名。
.cshtml
文件的存在会触发不同SDK的行为,需要AspNetCore.Mvc命名空间。虽然微软的人认为这是一个错误,可能会修复它。
卸载x86版本的.NET Core 3.0预览SDK


然后在Windows10上再次安装x64 64位为我解决了这个问题

缓存。1) 清理解决方案,2)关闭VS,3)删除bin/obj文件夹,4)重新打开VS这没有帮助。错误再次出现。发布所有软件包版本,您的VS版本,如果仍然适用,发布Blazor工具版本。您使用的是VS2019还是VS2019预览?(这是一个很大的区别)@HenkHolterman我刚刚添加了我的客户端包中引用的版本。我已经多次这样做了,但一旦我构建项目并重新打开文件,错误就会再次出现。@rabejens您是否尝试过重建。或者删除obj和bin文件夹并重新构建?是的,这行中的所有操作都没有用。@rabejens通常这应该清除intellisense缓存。但您可以尝试删除提到的文件夹,并重新启动windows。可能过多,但有时会有帮助:)我关闭了VS,执行了一个
git clean-fdx
,删除了所有这些文件夹,然后重新打开VS,但没有任何帮助。我只是对IntelliSense略知一二,我在使用C++/CLI访问第三方本机DLL时遇到了类似的问题,我也已经习惯了。我没有
cshtml
文件,但我会等到16.1版退出预览,直到现在我才对IntelliSense略知一二,正如我所说的,我对C++/CLI项目也有类似的问题,我已经习惯了这一点。我不知道cshtml是否有区别,但我确实在not preview和@rabejens中看到了相同的IntelliSense问题-您可以(对于Blazor来说可能应该)并排安装预览版。