dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.35k stars 9.99k forks source link

'Diagnostics' does not exist in the namespace 'Microsoft.AspNetCore' #18437

Closed Lobosque closed 4 years ago

Lobosque commented 4 years ago

I am under the process of upgrading my application from ASP.NET Core 2.2 to 3.1. When trying to import Diagnostics:

using Microsoft.AspNetCore.Diagnostics;

I am getting this error:

The type or namespace name 'Diagnostics' does not exist in the namespace 'Microsoft.AspNetCore'

The documentation page Handle errors in ASP.NET Core states that the Diagnostics package is under Microsoft.AspNetCore.App:

The Developer Exception Page displays detailed information about request exceptions. The page is made available by the Microsoft.AspNetCore.Diagnostics package, which is in the Microsoft.AspNetCore.App metapackage

The documentation page Microsoft.AspNetCore.App for ASP.NET Core states that when you target netcoreapp3.0, you don't have to worry about manually importing Microsoft.AspNetCore.App:

Projects that target the Microsoft.NET.Sdk.Web SDK implicitly reference the Microsoft.AspNetCore.App framework. No additional references are required for these projects.

I am actually targeting netcoreapp3.1, but that shouldn't be the issue.

What am I missing or doing wrong here?

To Reproduce

Further technical details

Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support): Version: 3.1.0 Commit: 65f04fb6db

.NET Core SDKs installed: 2.2.401 [C:\Program Files\dotnet\sdk] 2.2.402 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download



- The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version: VS Code 1.41.1
javiercn commented 4 years ago

@Lobosque thanks for contacting us.

I think you might have an issue with the migration. Check out the migration guide for breaking changes and instructions on what to do.

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#breaking-api-changes

Pilchie commented 4 years ago

@Lobosque Can you share your .csproj file? Is it possible that you aren't using the "Microsoft.Net.Web.Sdk" ?

ghost commented 4 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.