locked
Could not load type 'System.Web.Configuration.WebConfigurationManager' from assembly 'System.Web RRS feed

  • Question

  • User-540818677 posted

    I have the following CSOM code inside my ASP.NET CORE (.NET 5.0) inside visual studio 2019:-

    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'.

    Tuesday, March 30, 2021 8:15 PM

All replies