1

I am trying to execute the below code to retrieve details from Sharepoint using C#. It is giving error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

using (ClientContext spcontext = new ClientContext("siteURL"))
{
     spcontext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
     spcontext.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("UserName","Password");
     spcontext.Load(spcontext.Web, w => w.Title, w => w.ServerRelativeUrl, w => w.Lists);
     spcontext.ExecuteQuery();
     Console.WriteLine(spcontext.Web.ServerRelativeUrl);
}

My application is ASP.NET Core 3.1.

Wouter de Kort
  • 39,090
  • 12
  • 84
  • 103
RKh
  • 13,818
  • 46
  • 152
  • 265

1 Answers1

2

System.Web.Services does not exist on .NET Core.

davidfowl
  • 37,120
  • 7
  • 93
  • 103
  • In that case what is the solution? Any other Sharepoint library which works with .NET Core ? – RKh Aug 02 '21 at 10:55
  • I'm not aware of any. Maybe keep it in a .NET Framework process and call it from your .NET Core process over HTTP. – davidfowl Aug 03 '21 at 05:40
  • You mean I need to change the target framework to .NET 4 or rewrite the application in .NET Framework 4 ? – RKh Aug 03 '21 at 10:05
  • In the answer suggested here: https://stackoverflow.com/questions/62918952/alternative-save-openbinarydirect-methods-for-csom-for-sharepoint-online/62930801#62930801, I am not getting AuthenticationManager class and GetContext method. By added reference to OfficePnPCore, I got AuthenticationManager but there is no GetContext. – RKh Aug 03 '21 at 11:34