none
My.User.Name is NOW returning Empty String

    Question

  • I'm developing a largish application that has been using My.User.Name from it's first few lines of coding.  Now, reopening the project after the holiday it is returning an empty string.  Not one byte of code has changed from when it was working last week.  I've spent all day pulling my hair why the database isn't allowing me access only to discover it's this asinine VB.Net that's lost it's mind.

     

    Environment.UserName is working - for now.  And I can change the code to use that.  But, what could cause this basic little functionality to suddenly die?

    Tuesday, November 27, 2007 9:08 PM

Answers

  • Hi Paul,

     

    My guess is that your problem is one of two things:

     

    1)  The 'Authentication mode' for your Windows Application got changed.

    How to test:

    Double-click the 'My Project' node in the Solution Explorer

    Go to the Application tab and look at the 'Authentication mode' combo-box (third up from the bottom)

    It should be 'Windows' if you want this to get initialized during app startup

     

    2)  Some Windows behavior I can't begin to understand  Smile

    How to test:

    Check the value of the following property:

    System.Security.Principal.WindowsIdentity.GetCurrent.Name

    This is the FX property that should be getting called when you call My.User.Name

    If this is returning a null string, methinks something with the OS has changed...

     

    Hope that helps,

     

    Kevin

    Wednesday, November 28, 2007 2:32 AM
    Moderator
  • Somehow, the 'Enable Application Framework' got unchecked.  I have no idea how that happened, but when I checked it the My.User object started working again.

     

    Thanks for pointing me in the right direction.

     

    Wednesday, November 28, 2007 4:39 PM

All replies

  • Hi Paul,

     

    My guess is that your problem is one of two things:

     

    1)  The 'Authentication mode' for your Windows Application got changed.

    How to test:

    Double-click the 'My Project' node in the Solution Explorer

    Go to the Application tab and look at the 'Authentication mode' combo-box (third up from the bottom)

    It should be 'Windows' if you want this to get initialized during app startup

     

    2)  Some Windows behavior I can't begin to understand  Smile

    How to test:

    Check the value of the following property:

    System.Security.Principal.WindowsIdentity.GetCurrent.Name

    This is the FX property that should be getting called when you call My.User.Name

    If this is returning a null string, methinks something with the OS has changed...

     

    Hope that helps,

     

    Kevin

    Wednesday, November 28, 2007 2:32 AM
    Moderator
  • Somehow, the 'Enable Application Framework' got unchecked.  I have no idea how that happened, but when I checked it the My.User object started working again.

     

    Thanks for pointing me in the right direction.

     

    Wednesday, November 28, 2007 4:39 PM