PnP Provisioning Engine Extensibility Handlers: FileLoadException

Highlighted
New Contributor

I'm trying to use the PowerShell cmdlets and add my own extensibility handlers when using the Get-PnPProvisioningTemplate cmdlet.

 

I use the following PowerShell commands in the same directory as my custom class library:

 

$handler1 = New-PnPExtensbilityHandlerObject -Assembly MyProvider.dll -Type MyProvider.ListsProvider
Get-PnPProvisioningTemplate -Out .\test.xml -Force -Schema V201801 -ExensibilityHandlers $handler1 -Handlers ExtensibilityProviders

 

However, I keep getting the following error:

 

Get-PnPProvisioningTemplate : There was an exception invoking the custom extensibility provider. Assembly: MyProviders.dll, 
Type: MyProviders.ListsProvider. Exception System.IO.FileLoadException: Could not load file or assembly 'MyProviders.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
File name: 'MyProviders.dll'
   at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
   at System.Reflection.RuntimeAssembly.CreateAssemblyName(String assemblyString, Boolean forIntrospection, RuntimeAssembly& assemblyFromResolveEvent)
   at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.GetProviderInstance(ExtensibilityHandler handler)
   at OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.ExecuteExtensibilityExtractionCallOut(ClientContext ctx, ExtensibilityHandler handler, ProvisioningTemplate template, 
ProvisioningTemplateCreationInformation creationInformation, PnPMonitoredScope scope)
At line:1 char:1

Can anybody help me understand the issue?

5 Replies
Highlighted

I think it is caused by the schema you are trying to use. i thought the 201801 would be available starting in februari. try 201705

Highlighted

Really? hmm... I looked at their GitHub page and it shows 201801 as an approved version. That said, I'll try 201705 tomorrow when I get back into the job to make sure. I'll report back then.

Highlighted

Well as far as i know the schema is published but is not supported in the code yet

Highlighted

Ok. I have insured that I have the following environment and used the following cmdlets yet still receive the same error. Perhaps it is time for me to publish a bug report?

 

PowerShell Module

Name: SharePointPnPPowerShellOnline
Version: 2.18.1709.0

Nuget Package

<package id="SharePointPnPCoreOnline" version="2.18.1709.0" targetFramework="net452" />

Command

$handler1 = New-PnPExtensbilityHandlerObject -Assembly "MyProvider.dll" -Type MyProvider.ListsProvider
Get-PnPProvisioningTemplate -Force -Schema V201705 -ExtensibilityHandlers $handler1 -Handlers ExtensibilityProviders

Error Message

Get-PnPProvisioningTemplate : There was an exception invoking the custom extensibility provider. Assembly: MyProvider.dll, Type: MyProvider.ListsProvider. Exception System.IO.FileLoadException: Could not load file or assembly 'MyProvider.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
File name: 'MyProvider.dll'
at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
at System.Reflection.RuntimeAssembly.CreateAssemblyName(String assemblyString, Boolean forIntrospection, RuntimeAssembly& assemblyFromResolveEvent)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence
securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.GetProviderInstance(ExtensibilityHandler handler)
at OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.ExecuteExtensibilityExtractionCallOut(ClientContext ctx, ExtensibilityHandler handler, ProvisioningTemplate template,
ProvisioningTemplateCreationInformation creationInformation, PnPMonitoredScope scope)
At line:1 char:1

 

Highlighted

Hi @Anthony Conrad,

I've been able to avoid the error.


Here the correct commands:

Add-Type -Path "C:...\MyProvider.dll"
$handler = New-PnPExtensibilityHandlerObject -Assembly "MyProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" -type "MyProvider.ListsProvider"
Get-PnPProvisioningTemplate -Out test.xml -ExtensibilityHandlers $handler