Mahesh KP
Mahesh KP

Reputation: 6446

Weblogin with PNP Framework in ASP.NET web application

We got a requirement to connect SharePoint Online site from an ASP.NET web application and this needs to be done in user context.

For this we have used PNP.Framework package and followed the steps in the articles listed here:

https://pnp.github.io/pnpframework/using-the-framework/migrating-from-pnp-sites-core.html

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins-modernize/from-csom-to-pnp-libraries#introducing-the-pnp-framework-library

We used the interactive / weblogin option to create the AuthenticationManager class object as shown:

var authManager = AuthenticationManager.CreateWithInteractiveLogin(clientID, "http://localhost", tenantID);

using (var context = await authManager.GetContextAsync(siteURL))
{
}

When we tried to run this code, we get this error:

ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

The same option works when we try this from a console application. Can someone guide us what could the issue be when using this with a web application?

Upvotes: 0

Views: 72

Answers (0)

Related Questions