Power BI

Content by Charles Sterling

Accessing the My namespace for things like the logged in user name


Just recieved this question in email and thought i would post the answer on blog too:




Hey Chuck!

Just a really quick Q for you if you can remember this on top of your head at all…apparently there’s a new ‘My…something’ class within .Net 2 that allows you to access the currently logged on user.  We’ve searched on the net and I’m afraid we’re not quite specific enough!  Do you know this class and which namespace it’s in at all?




This functionality is in the Microsoft.VisualBasic namespace and can be accessed like below:




In C# you need to add a reference to the Namespace I referenced above and accessed via the following code:


//using Microsoft.VisualBasic;

Computer myComputer = new Computer();