I work on visual studio 2017 asp.net core 2.2 when create new api controller I get Error
- There was an error running the template C:\Users\ahmed.barbary\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\2.2.3\Templates\ControllerGenerator\ApiEmptyController.cshtml: Template Processing Failed:(4,47): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
- (10,41): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
- at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.
b__6_0() - at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
- at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
- at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
why this error happen and how to solve it
project file as controller project as below :
"Microsoft.NET.Sdk.Web"> "Globals" >SAK SAK SAK SAK netcoreapp2.2 "'$(Configuration)|$(Platform)'=='Release|AnyCPU'" >TRACE;RELEASE;NETCOREAPP;NETCOREAPP2_2 true portable true false "wwwroot\" />"Microsoft.AspNetCore.All" Version="2.0.0" />"Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />"Microsoft.Windows.Compatibility" Version="3.1.0" />"Serilog.Extensions.Logging.File" Version="2.0.0" />"Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />"..\Framework.Model\Framework.Model.csproj" />"..\Framework.MSSQL\Framework.MSSQL.csproj" />"..\Framework.Services\Framework.Services.csproj" />"Z2Data.Utils.BaseRepository" >..\..\..\dll\Z2Data.Utils.BaseRepository.dll "Z2Data.Utils.DataMappingHelper" >..\..\..\dll\Z2Data.Utils.DataMappingHelper.dll "Z2Data.Utils.DataProvider" >..\..\..\dll\Z2Data.Utils.DataProvider.dll
i write
dotnet --info
and result
- Microsoft Windows [Version 10.0.10586]
- (c) 2015 Microsoft Corporation. All rights reserved.
- C:\Windows\system32>dotnet --info
- .NET Core SDK (reflecting any global.json):
- Version: 2.2.110
- Commit: 4797dabd3c
- Runtime Environment:
- OS Name: Windows
- OS Version: 10.0.10586
- OS Platform: Windows
- RID: win10-x64
- Base Path: C:\Program Files\dotnet\sdk\2.2.110\
- Host (useful for support):
- Version: 2.2.8
- Commit: b9aa1abc51
- .NET Core SDKs installed:
- 1.1.14 [C:\Program Files\dotnet\sdk]
- 2.1.202 [C:\Program Files\dotnet\sdk]
- 2.1.509 [C:\Program Files\dotnet\sdk]
- 2.2.110 [C:\Program Files\dotnet\sdk]
- .NET Core runtimes installed:
- Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
- Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
- Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
- Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
- Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
- Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
- Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
- Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
- Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
so how to solve issue please
I can't create New api controller
Sachin SinghPosted May 19, 2021, 9:59 AM
ahmed elbarbaryPosted May 19, 2021, 10:30 AM
Sachin SinghPosted May 19, 2021, 10:19 AM
ahmed elbarbaryPosted May 19, 2021, 10:16 AM