title: Get Windows user C#
body: <p>I have a WPF application that needs to get the Windows username of the user. I am using the following line of code:</p>
  
  <p><code>MessageBox.Show("Your username is:\n" + WindowsIdentity.GetCurrent().Name);</code></p>
  
  <p>This works fine on my computer and computers of our other developers, but for others, it crashes. I'm assuming this is a permissions issue. Here is the error:</p>
  
  <pre><code>Problem signature:
  Problem Event Name: CLR20r3
  Problem Signature 01: notesformultipleproperties.exe
  Problem Signature 02: 1.0.0.0
  Problem Signature 03: 51cb04a1
  Problem Signature 04: PresentationFramework
  Problem Signature 05: 4.0.0.0
  Problem Signature 06: 504dc7da
  Problem Signature 07: 7b4d
  Problem Signature 08: 0
  Problem Signature 09: System.Windows.Markup.XamlParse
  OS Version: 6.1.7601.2.1.0.256.48
  Locale ID: 1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
  
  Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&amp;clcid=0x0409
  
  If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt
  </code></pre>
  
  <p>Can I allow this line of code to run no matter what permissions the user has?</p>