question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Object reference not set to an instance of an object" when provisioning ClientSidePages

See original GitHub issue

Version: >= 0.86.0-preview (currently trying 0.101.0-preview)

Issue

Object reference not set to an instance of an object. when applying a template (with ClientSidePage) to a web, using following code:

web.ApplyProvisioningTemplate(provisioningTemplate, applyingInformation);

Same code & template work when using a nuget package 0.84.0 for example. Seems to be introduced when PnP.Core was used for handling ClientSidePages (not sure if the issue lies in this library or with them). My template is very simple and only provisions 1 ClientSidePage.

Output:

01/02 - Initializing engine
02/02 - ClientSidePages

Stacktrace:

Object reference not set to an instance of an object. at
PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser) at
Microsoft.SharePoint.Client.WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation)

Peculiar thing: it does work without a problem when using PnP.PowerShell (latest nightly build, including PnP.Core 0.101.0-preview).

Steps to reproduce

  • Create a modern Communication Site
  • Apply the template with web.ApplyProvisioningTemplate (in code, as mentioned: PowerShell works). I had to upload as zip, so it needs renaming to pnp first.
  • See it fail with the Object reference not set error

SitePagesTemplate.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
YannickRecommented, Jan 6, 2021

I’m VERY sure, as the same code works without issue when using the older nuget packages.

Also, my AuthManager try doesn’t use the PnPProvisionContext and also fails, so that doesn’t seem to be the issue: image

Last thing I can think of, from the top of my head, are missing permission scopes. Is there a list of the minimal scopes you need to get provisioning to work now that we’re depending on PnP.Core? Using the source code for debugging will help clarify a lot. All of this are just educated guesses, I’ll have to dig a bit deeper to troubleshoot. Currently I am not blocked, by staying on the older preview. I’ll figure it out soon 😉

1reaction
YannickRecommented, Jan 5, 2021

@jansenbe I still encounter the issue, now when I’m using 0.1.102-preview. I run from nuget, and it includes PnP.Core 0.4.33-beta1. I’ll check if I can make a console app to reproduce, there must be something specific in my setup that triggers the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PnP Provisioning Template Object reference not set to ...
The template is trying to find federateddirectoryclaimprovider user for applying permissions to it, but is not able to find this user in ...
Read more >
Get-PnPProvisioningTemplate failing with Object reference ...
While processing the script "Client Side Page Contents" it fails with Object not reference,then we exclude the Client Side page content with ...
Read more >
"Object reference not set to an instance of an object" Error ...
This is due to a broken content database associated with the particular web application. Solution: Remove the invalid content database ...
Read more >
Apply-PnPTenantTemplate : Object reference not set to an ...
The fix was to run Uninstall-Module for the offending versions and then retry the Apply-PnPTenantTemplate.
Read more >
There has been an unexpected error "Object reference not ...
The message "object reference not set to an instance of an object" means that you are referring to an object the does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found