Why WindowsIdentity Class Does Not Display in .NET Core

The presence of code below in VisualStudio 2017. The .NET Core 2.0 Console Application

using System;
using System.Security.Principal;

namespace smallTests
{
    class Program
    {
        static void Main(string[] args)
        {
            var identity = WindowsIdentity.GetCurrent();
        }
    }
}

Why am I getting the error:

The name 'WindowsIdentity' does not exist in the current context    

If I see this class in the .NET Core 2.0 library in .NET Core docs ?

The same code works in the .NET Console application.

[EDIT]

@Will @JohnnyL Comments that I am not referring System.Security.Principal.Windows.dll, it is true.

But I am curious why it does not work, because in the .NET 4.6.1 project (where the WindowsIdentity class is visible) I also do not refer to this one System.Security.Principal.Windows.dllin particular. However, I refer to System.dll.

I always thought that it works like a namespace hierarchy. For example, when I refer to

System.Security.Principal.dll

I can use a class that is in

System.Security.Principal.Windows.dll.

I am wrong?

System.Security.Principal.dll .NetCore , - .

[EDIT2]

@Will , . , WindowsIdentity Core, , , , :

apisof.net Declarations , WindowsIdentity .Net Core 2.0 System.Security.Principal.Windows, Version=4.1.1.0, PublicKeyToken=b03f5f7f11d50a3a System.Security.Principal.Windows.dll , ? , ?

. NET Core api ( , ?

?

+4
1

Microsoft Windows .NET Core ,

https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/

, System.Security.Principal.Windows.csproj ,

https://github.com/dotnet/corefx/blob/master/src/System.Security.Principal.Windows/src/System.Security.Principal.Windows.csproj

, Windows , Windows.

, csproj PackageReference System.Security.Principal.Windows ( Visual Studio NuGet).

+7

Source: https://habr.com/ru/post/1690620/


All Articles