0

Having recently upgraded CSOM, loading the site object no longer works.

This has been an issue on all versions since 16.1.8029.1200..

Anyone else come across this issue and found a way round it?

We have connected the ClientContext to a number of different sites, and using the following..

ClientContext.Load(ClientContext.Site);
ClientContext.ExecuteQuery();

Comes back with the error:

The type of data at position 1185 is different than the one expected.

Currently our work around has been to downgrade to 16.1.7918.1200, which was the last working version that allowed this to work.

2
  • Raised this with MS and they mentioned that they are working on a fix for this. Nothing you can do at the moment :( Commented Mar 12, 2019 at 16:11
  • Ah, that's a shame! Good to know it's not just me though. Thanks.
    – James Amos
    Commented Mar 12, 2019 at 16:14

1 Answer 1

0

It working fine in my environment, check the steps below:

1.Create a Console Application using Visual Studio.

2.Install package below.

Install-Package Microsoft.SharePointOnline.CSOM -Version 16.1.8029.1200

3.Modify the code below and check if it works.

using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteUrl = "https://tenant.sharepoint.com/sites/lz";
            var login = "[email protected]";
            var password = "xxx";

            ClientContext context = new ClientContext(siteUrl);
            var securePassword = new SecureString();
            foreach (char c in password.ToCharArray()) securePassword.AppendChar(c);
            context.Credentials = new SharePointOnlineCredentials(login, securePassword);

            var site = context.Site;
            context.Load(context.Site);
            context.ExecuteQuery();
            Console.WriteLine(site.Id);
            Console.ReadKey();
        }
    }
}
1
  • Tried this code against 3 different tenants and I still encounter the same error in all 3. Is the tenant you are using in preview, or not? The tenants we are using are not in preview.
    – James Amos
    Commented Mar 13, 2019 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.