pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
416 stars 643 forks source link

Exception in CreateSiteAsync when using parameter owners in TeamSiteCollectionCreationInformation #2309

Open matsla opened 5 years ago

matsla commented 5 years ago

This code below is now throwing an exception when using TeamSiteCollectionCreationInformation with parameter Owners. It seems anyway that att owners defined in owners array are addedd to site. If i remove the owners parameter array it works fine.

The code works with SharePointPnPCoreOnline 3.10.1906 but this version is dependent of Newtonsoft.Json 11.0.1. As we are using Azure Functions and upgrading to Newtonsoft.Json 11.0.1 from 10.0.3 will get following error:

System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

Is it possible to build SharePointPnPCoreOnline 3.10.1906 and later versions with Newtonsoft.Json 10.0.3 to get this to work with azure functions?


SharePointPnPCoreOnline 3.8.1904 (Newtonsoft.Json 10.0.3)

var authManager = new OfficeDevPnP.Core.AuthenticationManager();

ClientContext ctx = authManager.GetSharePointOnlineAuthenticatedContextTenant( "https://xxxx.sharepoint.com", "xx@xx.onmicrosoft.com", "xx");

string[] owners = new string[2]; owners[0] = "x@x.onmicrosoft.com"; owners[1] = "y@y.onmicrosoft.com";

var teamSiteContext = await ctx.CreateSiteAsync( new TeamSiteCollectionCreationInformation { Alias = "TEST4", DisplayName = "TEST4", Description = string.Empty, IsPublic = false, Lcid = 1033, Owners = owners });

=> Exception is throw

Stack Trace:

  Name Value Type
  StackTrace " at OfficeDevPnP.Core.Sites.SiteCollection.d3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.SharePoint.Client.ClientContextExtensions.d24.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n

Message:

  Name Value Type
  Message "{\"DocumentsUrl\":null,\"ErrorMessage\":null,\"GroupId\":\"36aeeeb6-51fc-443e-b630-10fdbc0b2bfe\",\"SiteStatus\":1,\"SiteUrl\":null}" string

Category

[X ] Bug [ ] Enhancement

Environment

[X ] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Thanks for your contribution! Sharing is caring.

ghost commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

kenneho commented 5 years ago

@matsla , did you get this working, and if so would you mind sharing the steps needed to get this up and running?

matsla commented 5 years ago

@kenneho , To solve the assembly binding issue with 'Newtonsoft.Json' after update SharePointPnPCoreOnline to latest version:

  1. Update NuGet package Newtonsoft.Json to 11.0.2
  2. Update NuGet package SharePointPnPCoreOnline to latest version
  3. Delete the local NuGet packages folder
  4. Rebuild solution
  5. Publish Azure Function
kenneho commented 5 years ago
  1. Delete the local NuGet packages folder

Thanks for you input. By deleting the local NuGet packages folder, you're referring clearing all caches like dotnet nuget locals all --clear?

matsla commented 5 years ago

@kenneho , It's the packages folder under your solution folder i.e ...source\'your vs solution'\packages. This folder contains all the NuGet packages used by the solution and all versions.

asestromsrud commented 5 years ago

I'm also having this trouble. Though I'm trying to create a Teamsite without O365 group var teamContext = await spContext.CreateSiteAsync( new TeamNoGroupSiteCollectionCreationInformation(fullUrl, title) ); I tried the solution above @matsla but with no success

asestromsrud commented 4 years ago

Is there any progress in solving this issue?