I am attempting to create a user control in Visual Studio 2019 using C#. Place the authentication portion of my code into the <control>_load.
On attempting to drag the control to my form, I get a "Failed To Create Component...". In a form or in dll it seems to work. Is using Microsoft Graph in a user control something we should not do?
Here a snippet of the control code:
private async void UserControl1_Load(object sender, EventArgs e)
{
confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(ClientId)
.WithTenantId(Tenant)
.WithClientSecret(cSecret)
.Build();
authProvider = new ClientCredentialProvider(confidentialClientApplication);
NoteBookHandler = GraphClientFactory.CreateDefaultHandlers(authProvider);
OutlookHttpClient = GraphClientFactory.Create(authProvider);
OutlookClient = new GraphServiceClient(OutlookHttpClient);
object MyFolders = await OutlookClient.Users["******@cga.ct.gov"].MailFolders.Request().Top(100).GetAsync();![73499-msgrapherror1.jpg][1]
}
Also, attached is an image of the error.
Gerry