question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft.Aspnetcore.Authorization namespace is missing with .NET Core 2.2

See original GitHub issue

Microsoft.Aspnetcore.Authorization namespace is missing when using .NET Core 2.2

To Reproduce

  1. Set TargetFramework of .csproj file to “netcoreapp2.2”
  2. Set RuntimeFrameworkVersion to “2.2.0”
  3. Include PackageReference “Microsoft.AspNetCore.App”
  4. Try to use Authorize attribute or to Microsoft.AspNetCore.Authorization namespace in any controller.
  5. Namespace is not found.
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
    <DebugType>Full</DebugType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"/>
  </ItemGroup>
</Project>

Expected behavior Running the same project with net core 2.1 works fine. Tried to include Microsoft.AspNetCore.Authorization package explicitly using nuget with no success. Error appears to be the same.

Screenshots image

Desktop:

  • OS: Windows 10 x64
  • IDE: Visual Studio 15.9.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jonnalecommented, Dec 27, 2018

I just had this same exact issue pop-up again, but this time with the Microsoft.AspNetCore.Authentication.Cookies package.

I installed this package to my project using Install-Package Microsoft.AspNetCore.Authentication.Cookies -Version 2.2.0. After doing that, I still could not reference it in my project. When I highlighted the dependency in my project and looked at the properties, I saw the Path for that package was set to C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.2.0

I went in and removed the entire folder C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies and then did a package restore in VS. After doing this, I noticed it updated the Path to C:\Users\<my user name>\.nuget\packages\microsoft.aspnetcore.authentication.cookies\2.2.0.

I then rebuilt the project and everything worked. I can now reference Microsoft.AspNetCore.Authentication.Cookies.

I would not be surprised if this was the same issue.

0reactions
Eiloncommented, Jan 1, 2019

Thanks for the extra info @jonnale . It’s not clear to us the exact cause for this but if anyone has exact steps to reproduce this problem, please upload your project to a GitHub repo with instructions on what to install, what to run, etc., and we can try to investigate more. In the meantime I’m closing this issue because there’s no immediate action for us to take here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.Aspnetcore.Authorization namespace is missing ...
AspNetCore.Authorization namespace in any controller. Namespace is not found. ... Running the same project with net core 2.1 works fine. Tried to ...
Read more >
Error CS0234: The type or namespace name 'AspNetCore ...
Error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Read more >
Migrate from ASP.NET Core 2.2 to 3.0
Learn how to migrate an ASP.NET Core 2.2 project to ASP. ... if an authorization or CORS policy is skipped due to missing...
Read more >
Microsoft.AspNetCore.Authorization Namespace
Contains types that enable support for authorization. The main types are IAuthorizationRequirement (marker interface representing a requirement which must ...
Read more >
ASP.NET Core breaking changes for versions 3.0 and 3.1
Lists the breaking changes in ASP.NET Core 3.0 and 3.1. ... NET Core 2.2, follow the guidance in the obsolete build messages to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found