I have a code to work with SharePoint by using CSOM. It is roughly the same for SharePoint 2016 and SharePoint Online, except for few lines. I want that my application work both with SharePoint 2016 and SharePoint Online simultaneously.
However, I cannot achieve this. If I install NuGet package for SharePoint Online, code runs fine with SharePoint Online but fails with SharePoint 2016. If I install NuGet package for SharePoint 2016, code runs fine with SharePoint 2016 but fails with SharePoint Online. How to make an application, which can work with both servers at the same time?
It seems that both NuGet packages use equally named SharePoint CSOM assemblies, which just replace one another and cannot coexist. Errors are standard for unresolved methods in CSOM, such as:
Cannot find stub for type with id "{154360b4-899f-4237-b0ed-3e35f014c748}". The specified server may not support APIs used in this operation. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream
Any ideas and suggestions are much appreciated.