If you make use of the My.User object in a WinForms application, you can just dive right into it and start using it right away, however, if you add this to a new console app it returns a blank response for My.User.Name:
Console.WriteLine("User: {0}", My.User.Name)
Console.ReadLine()
And you'll see this when you run it:
To get around this problem, all it takes is an initialization that gets called automagically in WinForms:
My.User.InitializeWithWindowsUser()
Put that before you use the object for the first time and you'll be good to go!
Technorati Tags:
.NET Tip,
My.User