none
My.User.Name is returning null in Visual studio 2017 and .net framework 4.7.0 RRS feed

  • Question

  • <p>Hi Everyone,</p><p>Currently am migration an application from .net framework 3.5 to .net framework 4.7 visual studio 2017.</p><p>Here am facing a different problem using visual studio, is like when i launched application using 2015 or 2017 VS, My.User.Name value is returning null (where the same is working good in the older versions) Here am not changing anything like framework of the current code.</p><p>Can some one please suggest some way to overcome the problem. Here i can not change any piece of code.&nbsp;</p><p>Below is the outputs on two different versions.</p><p>Visual studio 2008</p><p><img alt="" src="https://social.msdn.microsoft.com/Forums/getfile/1243876" /></p><p>Visual Studio 2017</p><p><img alt="" src="https://social.msdn.microsoft.com/Forums/getfile/1243878" /></p><p></p><p>Please suggest some possible way.</p>
    Friday, March 23, 2018 9:33 AM

All replies

  • Yea I've that to, but never use that. 

    You can use 

    Environment.UserName
    If you want to report it as bug you can do that inside Visual Studio. 


    Success
    Cor


    Friday, March 23, 2018 11:18 AM
  • Hi Pabba,

    Please provide your code related with getting "My.User.Name".

    # I have no idea where you are writing your post.
       But I know there are many <tag> in your post, and it makes very hard for me to read.
       I hope you will remove so many unnecessary tags from your post.

    Regards,

    Ashidacchi &gt;&gt; http://hokusosha.com/

    Friday, March 23, 2018 11:29 AM
  • I think it depends upon the type of application you are working with. In some instances you need to call the following:

    My.User.InitializeWithWindowsUser()

    As Cor mentioned there are other solutions as well. I generally use:

    System.Security.Principal.WindowsIdentity.GetCurrent().Name


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Friday, March 23, 2018 12:42 PM