I have the following CSOM code inside my ASP.NET CORE (.NET 5.0):-
var siteUrl = config.GetSection("SP").GetSection("SiteURL").Value;
string clientId = "****";
string clientSecret = "***";
using (ClientContext context = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret))
{
but i am getting this error:-
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'OfficeDevPnP.Core.Utilities.TokenHelper' threw an exception.
Source=OfficeDevPnP.Core
StackTrace:
at OfficeDevPnP.Core.Utilities.TokenHelper.set_Realm(String value)
at OfficeDevPnP.Core.AuthenticationManager.EnsureToken(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix)
at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix)
at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String appId, String appSecret)
at ServiceDeskSharePointIntegration.Program.Main(String[] args) in C:\Users\****\source\repos\ServiceDeskSharePointIntegration\ServiceDeskSharePointIntegration\Program.cs:line 47
Inner Exception 1:
TypeLoadException: Could not load type 'System.Web.Configuration.WebConfigurationManager' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
when i hover over the related package i got this error:-