Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Could not load type 'Microsoft.SharePoint.Client.AuditMaskType' from assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. #1025

Closed
VesaJuvonen opened this issue Jan 31, 2017 · 13 comments

Comments

@VesaJuvonen
Copy link
Contributor

From @virendramunot on January 19, 2017 10:59

I am using PNP PnP Provisioning Engine code to create site on my on-prem sharepoint 2013 environment. Below is the snapshot of the code which I wrote on remote server using Console App.

ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(ctx.Web);

                // Create FileSystemConnector to store a temporary copy of the template 
                ptci.FileConnector = new FileSystemConnector(@"c:\temp\pnpprovisioningdemo", string.Empty);
                ptci.PersistBrandingFiles = true;

                ptci.ProgressDelegate = delegate(String message, Int32 progress, Int32 total)
                {
                    // Only to output progress for console UI
                    Console.WriteLine("{0:00}/{1:00} - {2}", progress, total, message);
                };

                // Execute actual extraction of the template
                template = ctx.Web.GetProvisioningTemplate(ptci);

                // We can serialize this template to save and reuse it
                // Optional step 
                XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(@"E:\PNP\pnpprovisioningdemo", string.Empty);
                provider.SaveAs(template, "PnPProvisioningDemo.xml");

The error is thrown at this line template = ctx.Web.GetProvisioningTemplate(ptci);

I have latest SharePoint Client SDK and Latest Provisioning engine DLL.

Not sure what this error. Any help will be appreciated.

Copied from original issue: pnp/PnP-Tools#106

@jansenbe
Copy link
Contributor

jansenbe commented Feb 3, 2017

The auditmaskType enum is available in the latest of all 3 csom flavors (online = 16.1, 2016 = 16.0 and 2013 = 15.0). Based on your error message you're using 2016 csom (version 16.0) against 2013 SharePoint. Can you reproduce this issue using the latest engine version in combination with the correct 2013 CSOM assemblies?

@dannyfoncke
Copy link

I seem to have the same problem
SharePoint 2013 - development single server
site to export = publishing site
error :
Get-PnPProvisioningTemplate : Could not load type 'Microsoft.SharePoint.Client.AuditMaskType' from assembly
'Microsoft.SharePoint.Client, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
At line:1 char:1

  • Get-PnPProvisioningTemplate -Out template.xml
  •   + CategoryInfo          : WriteError: (:) [Get-PnPProvisioningTemplate], TypeLoadException
      + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.GetProvisioningTemplate
    

@virendramunot
Copy link

Please download the newest version of PNP Core engine and it should be resolved.

@jansenbe
Copy link
Contributor

As mentioned by @virendramunot this should be fixed as of the Feb release. We loaded online CSOM for on-premises nuget packages resulting in this issue. If you can stil repro with the latest (March 2017) version then please re-open the issue.

@virendramunot
Copy link

Hey, I have update my code with new PNP package and now getting the same error again. Has something change from the previous version which I need to change.
Appreciate your prompt response .

The error description is below:

System.TypeLoadException was unhandled
HResult=-2146233054
Message=Could not load type 'Microsoft.SharePoint.Client.AuditMaskType' from assembly 'Microsoft.SharePoint.Client, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
Source=OfficeDevPnP.Core
TypeName=Microsoft.SharePoint.Client.AuditMaskType
StackTrace:
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLPnPSchemaV201605Formatter.ToProvisioningTemplate(Stream template, String identifier)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLPnPSchemaFormatter.ToProvisioningTemplate(Stream template, String identifier)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(String uri, String identifier, ITemplateFormatter formatter, ITemplateProviderExtension[] extensions)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(String uri, ITemplateProviderExtension[] extensions)
at OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider.GetTemplate(String uri)
at TestPNP.Program.ApplyProvisioningTemplate(String NewSubsiteURL) in E:\Virendra\TestPNP\TestPNP\Program.cs:line 32
at TestPNP.Program.Main(String[] args) in E:\Virendra\TestPNP\TestPNP\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Thanks in Advance.

@VesaJuvonen VesaJuvonen reopened this May 8, 2017
@virendramunot
Copy link

HI Vesa
Thanks for opening this ...Just wanted to let you know that I have resolved this issue. The issue was regarding VS2015. I was trying to run the code using VS2015 and for this studio need to get updated Microsoft.SharePoint.Client.Dll to get the PNP code working. I installed the Latest Microsoft.SharePoint.Client.DLL and things started working.
Thanks again for your prompt response.

You can close this now.

Regards
Virendra Jain

@VesaJuvonen
Copy link
Contributor Author

thx virendramunot for following up on this and sharing the solution for others who might be running into to the same issue.

@jpcostach
Copy link

Same issue here.
Trying to get the provisioning template from a SharePoint 2013 site, using the PnPCore for SharePoint 2013. Same error, no solution.

@virendramunot
Copy link

What VS version you are using? If VS2015 then download the latest Microsoft.SharePoint.Client DLL from MSDN.

@VesaJuvonen
Copy link
Contributor Author

Please note that you should NOT use CSOM SDKs from MS download, rather ensure that you are using NuGet packages, which are automatically associated in the solutions. If you have SDK installed, that adds assemblies to GAC, which can override references for on-premises. With SPO, this is not a problem, since fully qualified assembly name is different between SDK and NuGet. NuGet CSOM is always is the latest for SPO... for on-premises, this is slightly more complex since also server version impacts on behavior. For the on-premises NuGets, see following - https://dev.office.com/blogs/sharepoint-csom-versions-for-on-premises-released-as-nuget-packages.

@virendramunot
Copy link

Agreed Vesa...but even the latest Nuget Package didnt resolve the issue for me when I downloaded VS2015. So I installed the latest Client SDK from MS and it worked. So suggested.

@SathishNadarajan
Copy link

Hi Vesa,

I am facing similar problem. I am getting an exception

Could not load type 'Microsoft.SharePoint.Client.ClientRequestWrapper' from assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

The piece of code, which I am trying to execute is,

this.SourceClientContext.Load(SourceClientContext.Web);
await this.SourceClientContext.ExecuteQueryRetryAsync();

I am using VS 2017 and the Nuget Packages
Microsoft.SharePointOnline.CSOM - V 16.1.8412.1200 And
SharePointPnPCoreOnline - V 3.5.1901.

Any help would be highly helpful.

@fewlines4biju
Copy link

HI... Yes I am too getting the same issue in Visual Studio 2017. Did you manage to resolve it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants