2

I have a simple wpf sample(a window with a button) .I set Thread.CurrentPrincipal in constructor like:

//my Window constructor
public Window1(){
InitializeComponent();
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());   
}

and I watch that Thread.CurrentPrincipal is correct.

I put a breakepoint in buttonclick event .after I click button I check Thread.CurrentPrincipal but it's change and my it's identity Name is empty

M.Azad
  • 3,673
  • 8
  • 47
  • 77
  • Can you post example code? Is it still the same thread? Are the other values of the current thread still the same? For example the managed thread id? – nvoigt Apr 09 '15 at 06:48
  • @nvoigt It has just this code.I add watch on Thread.CurrentPrincipal.Identity.Name in constructor and i see my windows username.aftre i click on button my watch value be empty... – M.Azad Apr 09 '15 at 06:53
  • Constructor of what? – H H Apr 09 '15 at 08:16
  • @HenkHolterman my Window constructor – M.Azad Apr 09 '15 at 08:27
  • It helps to be clear about that. Also about the InitializeComponent() that's usually there (before/after/removed?) – H H Apr 09 '15 at 09:23
  • For what it's worth, I can confirm this. It does stick when set in the button-event but somehow it's reset after Window_Loaded, the last startup event that I know of. – H H Apr 09 '15 at 09:27
  • @HenkHolterman I set CurrentPrincipal after InitializeComponent() – M.Azad Apr 09 '15 at 09:29
  • 1
    I am seeing the same thing, it's frustrating. – WeSam Abdallah Nov 10 '15 at 20:51

0 Answers0