c# - Accessing current Microsoft account from Visual Studio extension -


i writing vs extension need communicate server , identify user, , figured if possible, since extension client connecting server, using visual studio's built-in support microsoft accounts make more sense implementing own account management infrastructure.

at first, because of variety of useful apis available visual studio developer, 1 might think getting info on current user easy. however, there don't seem obvious apis can used access accounts; checked here , there weren't related services listed (the "profile" services allow read/write settings stored current user).

does know of (relatively) simple way access microsoft account visual studio extension?

edit

i tried hadi brais's suggestion, , @ first appeared work (i retrieved information); however, each time, visual studio crash 30s afterward. commented out lines interacted registry , replaced them static values variables, , crashes stopped. clearly, accessing visual studio's registry keys causing crash. tried using statements , other safeguards, there doesn't seem way safely access visual studio registry keys extension. know of official apis can used retrieve information without crashing visual studio?

for visual studio 2015 (version 14.0), how information user signed in in visual studio. need add using microsoft.win32;.

private static string getuseremailaddressvs14() {     // it's practice request explicit permission     // user want use email address ,     // other information. enables user in control     // of his/her privacy.      // assuming permission granted, obtain email address.      const string subkey = "software\\microsoft\\vscommon\\connecteduser\\ideuser\\cache";     const string emailaddresskeyname = "emailaddress";     const string usernamekeyname = "displayname";      registrykey root = registry.currentuser;     registrykey sk = root.opensubkey(subkey);     if (sk == null)     {         // user not signed in.         return null;     }     else     {         // user email address.         return (string)sk.getvalue(emailaddresskeyname);          // can user name this.         // return (string)sk.getvalue(usernamekeyname);     } } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -