我使用以下命令创建了 .net core 2.0 mvc 应用程序:“dotnet new mvc”,它运行没有任何问题,但在 vscode 中我有两个错误:
'IServiceCollection' does not contain a definition for 'AddMvc' and no extension method 'AddMvc' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)'
'IApplicationBuilder' does not contain a definition for 'UseStaticFiles' and no extension method 'UseStaticFiles' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) '
我正在使用:Linux elementary OS 0.4.1 Loki、.net core 2.0、vscode 1.15.1。
最佳答案
加载项目时,您的 Nuget 还原可能失败。尝试从命令行运行 dotnet restore
。
还要检查以确保在使用 .AddMVC()
和 .UseStaticFiles( )
关于c# - 'IServiceCollection' 不包含 'AddMvc' 的定义, 'IApplicationBuilder' 不包含 'UseStaticFiles' 的定义,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45763970/