title: Why WindowsIdentity class is not visible in .NET Core
body: <p>Having the code below in VisualStudio 2017 .NET Core 2.0 Console App</p>
  
  <pre><code>using System;
  using System.Security.Principal;
  
  namespace smallTests
  {
      class Program
      {
          static void Main(string[] args)
          {
              var identity = WindowsIdentity.GetCurrent();
          }
      }
  }
  </code></pre>
  
  <p>Why am I getting the error: </p>
  
  <pre><code>The name 'WindowsIdentity' does not exist in the current context    
  </code></pre>
  
  <p>If I can see this class in .NET Core 2.0 library in <a href="https://docs.microsoft.com/en-us/dotnet/api/system.security.principal.windowsidentity?view=netcore-2.0" rel="noreferrer">.Net Core docs</a> ?</p>
  
  <p>Same code works in .NET Console app. </p>
  
  <p><strong>[EDIT]</strong> </p>
  
  <p><strong>@Will @JohnnyL</strong> Commented that I do not refer, <code>System.Security.Principal.Windows.dll</code>, that is true. </p>
  
  <p>But I am curious why it is not working, because
  in .NET 4.6.1 project (where class WindowsIdentity is visible) I also do not refer this <code>System.Security.Principal.Windows.dll</code> specifically. However i refer System.dll.</p>
  
  <p>I always thought that it works like namespace hierarchy. For instance, when I refer to </p>
  
  <p><code>System.Security.Principal.dll</code> </p>
  
  <p>i can use class which is in </p>
  
  <p><code>System.Security.Principal.Windows.dll</code>. </p>
  
  <p>Am I wrong?</p>
  
  <p>I added <code>System.Security.Principal.dll</code> to .NetCore solution by hand but it still does not work.</p>
  
  <p><strong>[EDIT2]</strong></p>
  
  <p><strong>@Will</strong> Thank you a lot for expaining the subject it helped me a lot. 
  I tried to figure out is WindowsIdentity compatible with Core and it seems that it is please see:</p>
  
  <p>in this <a href="https://apisof.net/catalog/System.Security.Principal.WindowsIdentity" rel="noreferrer">apisof.net</a> in Declarations area i can see that WindowsIdentity is in <code>.Net Core 2.0   System.Security.Principal.Windows, Version=4.1.1.0, PublicKeyToken=b03f5f7f11d50a3a</code>
  but i do not have <code>System.Security.Principal.Windows.dll</code> in references, should I add it? If yes from where?</p>
  
  <p>in <a href="https://docs.microsoft.com/en-us/dotnet/api/?view=netcore-2.0&amp;term=WindowsIdentity" rel="noreferrer">.NET Core api reference</a> i see this class in the list (what is the purpose of that listing if it is not compatible with core?</p>
  
  <p>I also find information about that class in <a href="https://source.dot.net/#System.Security.Principal.Windows/System/Security/Principal/WindowsIdentity.cs,200d683bfb324fda" rel="noreferrer">that link</a></p>
  
  <p>Am I looking in wrong places? </p>