Click here to Skip to main content
15,879,326 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 5:36
professionalRichard Andrew x641-Aug-20 5:36 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 6:07
arnold_w1-Aug-20 6:07 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 6:10
professionalRichard Andrew x641-Aug-20 6:10 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 6:15
arnold_w1-Aug-20 6:15 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 6:21
professionalRichard Andrew x641-Aug-20 6:21 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
arnold_w1-Aug-20 6:51
arnold_w1-Aug-20 6:51 
GeneralRe: How can I get handle (IntPtr) to a "sub"-form in another application? Pin
Richard Andrew x641-Aug-20 7:05
professionalRichard Andrew x641-Aug-20 7:05 
QuestionAzure Active Directory question Pin
pkfox31-Jul-20 0:50
professionalpkfox31-Jul-20 0:50 
Hi all I have this method in a class which tries to get an access token from Azure Active Directory - it works if I use it in a Net Core app but hangs forever when I try to use it in a Winforms app
C#
private async Task GetAccessToken()
       {
            // Utils.GetAppConfigSetting just reads keys in App.config
           string Instance = Utils.GetAppConfigSetting("Instance");
           string TenantID = Utils.GetAppConfigSetting("TenantID");
           string ClientID = Utils.GetAppConfigSetting("ClientID");
           string ClientSecret = Utils.GetAppConfigSetting("ClientSecret");
           string BaseAddress = Utils.GetAppConfigSetting("BaseAddress");
           string ResourceID = Utils.GetAppConfigSetting("ResourceID");
           string APIServer = Utils.GetAppConfigSetting("APIServer");
           string Authority = String.Format(CultureInfo.InvariantCulture,Instance, TenantID);

           this.App = ConfidentialClientApplicationBuilder.Create(ClientID)
               .WithClientSecret(ClientSecret)
               .WithAuthority(new Uri(Authority))
               .Build();

           this.ResourceIds = new string[] { ResourceID };

           // this is where it hangs !!
           this.Result = await this.App.AcquireTokenForClient(this.ResourceIds).ExecuteAsync();
           this.AccessToken = this.Result.AccessToken;

           // this.Client is a RestSharp client
           this.Client.Authenticator = new JwtAuthenticator(this.AccessToken);
       }
// I call it with this code
this.GetAccessToken().GetAwaiter().GetResult();

there is no error it just hangs - any ideas ?

Edit

It must be the UI thread in Winforms as I just tried the same code in a Console App and it worked perfectly
"We can't stop here - this is bat country" - Hunter S Thompson - RIP


modified 31-Jul-20 9:51am.

AnswerRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 0:01
mveRichard Deeming4-Aug-20 0:01 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 3:36
professionalpkfox4-Aug-20 3:36 
GeneralRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 3:40
mveRichard Deeming4-Aug-20 3:40 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 5:38
professionalpkfox4-Aug-20 5:38 
GeneralRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 5:48
mveRichard Deeming4-Aug-20 5:48 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 6:52
professionalpkfox4-Aug-20 6:52 
GeneralRe: Azure Active Directory question Pin
Richard Deeming4-Aug-20 23:14
mveRichard Deeming4-Aug-20 23:14 
GeneralRe: Azure Active Directory question Pin
pkfox5-Aug-20 3:12
professionalpkfox5-Aug-20 3:12 
GeneralRe: Azure Active Directory question Pin
pkfox4-Aug-20 23:12
professionalpkfox4-Aug-20 23:12 
QuestionHow to change the aspect ratio of an Windows media player by using C# Pin
Member 1488657531-Jul-20 0:25
Member 1488657531-Jul-20 0:25 
AnswerRe: How to change the aspect ratio of an Windows media player by using C# Pin
Gerry Schmitz31-Jul-20 7:32
mveGerry Schmitz31-Jul-20 7:32 
QuestionName Generator Pin
Brandnoob30-Jul-20 8:04
Brandnoob30-Jul-20 8:04 
AnswerRe: Name Generator Pin
Gerry Schmitz30-Jul-20 8:10
mveGerry Schmitz30-Jul-20 8:10 
AnswerRe: Name Generator Pin
OriginalGriff30-Jul-20 8:55
mveOriginalGriff30-Jul-20 8:55 
QuestionExecuteScalar to cshtml view Pin
Member 1490312930-Jul-20 5:30
Member 1490312930-Jul-20 5:30 
AnswerRe: ExecuteScalar to cshtml view Pin
Gerry Schmitz30-Jul-20 8:02
mveGerry Schmitz30-Jul-20 8:02 
GeneralRe: ExecuteScalar to cshtml view Pin
Member 1490312930-Jul-20 11:42
Member 1490312930-Jul-20 11:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.