PnP Provisioning Engine Extensibility Handlers: FileLoadException

%3CLINGO-SUB%20id%3D%22lingo-sub-145647%22%20slang%3D%22en-US%22%3EPnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145647%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20use%20the%20PowerShell%20cmdlets%20and%20add%20my%20own%20extensibility%20handlers%20when%20using%20the%20Get-PnPProvisioningTemplate%20cmdlet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20use%20the%20following%20PowerShell%20commands%20in%20the%20same%20directory%20as%20my%20custom%20class%20library%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24handler1%20%3D%20New-PnPExtensbilityHandlerObject%20-Assembly%20MyProvider.dll%20-Type%20MyProvider.ListsProvider%0AGet-PnPProvisioningTemplate%20-Out%20.%5Ctest.xml%20-Force%20-Schema%20V201801%20-ExensibilityHandlers%20%24handler1%20-Handlers%20ExtensibilityProviders%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20I%20keep%20getting%20the%20following%20error%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EGet-PnPProvisioningTemplate%20%3A%20There%20was%20an%20exception%20invoking%20the%20custom%20extensibility%20provider.%20Assembly%3A%20MyProviders.dll%2C%20%0AType%3A%20MyProviders.ListsProvider.%20Exception%20System.IO.FileLoadException%3A%20Could%20not%20load%20file%20or%20assembly%20'MyProviders.dll'%20or%20one%20of%20its%20dependencies.%20The%20given%20assembly%20name%20or%20codebase%20was%20invalid.%20(Exception%20from%20HRESULT%3A%200x80131047)%0AFile%20name%3A%20'MyProviders.dll'%0A%20%20%20at%20System.Reflection.AssemblyName.nInit(RuntimeAssembly%26amp%3B%20assembly%2C%20Boolean%20forIntrospection%2C%20Boolean%20raiseResolveEvent)%0A%20%20%20at%20System.Reflection.RuntimeAssembly.CreateAssemblyName(String%20assemblyString%2C%20Boolean%20forIntrospection%2C%20RuntimeAssembly%26amp%3B%20assemblyFromResolveEvent)%0A%20%20%20at%20System.Activator.CreateInstance(String%20assemblyString%2C%20String%20typeName%2C%20Boolean%20ignoreCase%2C%20BindingFlags%20bindingAttr%2C%20Binder%20binder%2C%20Object%5B%5D%20args%2C%20CultureInfo%20culture%2C%20Object%5B%5D%20activationAttributes%2C%20Evidence%20securityInfo%2C%20StackCrawlMark%26amp%3B%20stackMark)%0A%20%20%20at%20System.Activator.CreateInstance(String%20assemblyName%2C%20String%20typeName)%0A%20%20%20at%20OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.GetProviderInstance(ExtensibilityHandler%20handler)%0A%20%20%20at%20OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.ExecuteExtensibilityExtractionCallOut(ClientContext%20ctx%2C%20ExtensibilityHandler%20handler%2C%20ProvisioningTemplate%20template%2C%20%0AProvisioningTemplateCreationInformation%20creationInformation%2C%20PnPMonitoredScope%20scope)%0AAt%20line%3A1%20char%3A1%3C%2FPRE%3E%0A%3CP%3ECan%20anybody%20help%20me%20understand%20the%20issue%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-214231%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-214231%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CSPAN%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F98389%22%20target%3D%22_blank%22%3E%40Anthony%20Conrad%3C%2FA%3E%3C%2FSPAN%3E%2C%3C%2FP%3E%3CP%3EI've%20been%20able%20to%20avoid%20the%20error.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EHere%20the%20correct%20commands%3A%3C%2FP%3E%3CP%3EAdd-Type%20-Path%20%22C%3A...%5CMyProvider.dll%22%3CBR%20%2F%3E%24handler%20%3D%20New-PnPExtensibilityHandlerObject%20-Assembly%20%22MyProvider%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull%22%20-type%20%22MyProvider.ListsProvider%22%3CBR%20%2F%3EGet-PnPProvisioningTemplate%20-Out%20test.xml%20-ExtensibilityHandlers%20%24handler%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-146066%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-146066%22%20slang%3D%22en-US%22%3E%3CP%3EOk.%20I%20have%20insured%20that%20I%20have%20the%20following%20environment%20and%20used%20the%20following%20cmdlets%20yet%20still%20receive%20the%20same%20error.%20Perhaps%20it%20is%20time%20for%20me%20to%20publish%20a%20bug%20report%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPowerShell%20Module%3C%2FP%3E%0A%3CPRE%3EName%3A%20SharePointPnPPowerShellOnline%0AVersion%3A%202.18.1709.0%3C%2FPRE%3E%0A%3CP%3ENuget%20Package%3C%2FP%3E%0A%3CPRE%3E%26lt%3Bpackage%20id%3D%22SharePointPnPCoreOnline%22%20version%3D%222.18.1709.0%22%20targetFramework%3D%22net452%22%20%2F%26gt%3B%3C%2FPRE%3E%0A%3CP%3ECommand%3C%2FP%3E%0A%3CPRE%3E%24handler1%20%3D%20New-PnPExtensbilityHandlerObject%20-Assembly%20%22MyProvider.dll%22%20-Type%20MyProvider.ListsProvider%0AGet-PnPProvisioningTemplate%20-Force%20-Schema%20V201705%20-ExtensibilityHandlers%20%24handler1%20-Handlers%20ExtensibilityProviders%3C%2FPRE%3E%0A%3CP%3EError%20Message%3C%2FP%3E%0A%3CPRE%3EGet-PnPProvisioningTemplate%20%3A%20There%20was%20an%20exception%20invoking%20the%20custom%20extensibility%20provider.%20Assembly%3A%20MyProvider.dll%2C%20Type%3A%20MyProvider.ListsProvider.%20Exception%20System.IO.FileLoadException%3A%20Could%20not%20load%20file%20or%20assembly%20'MyProvider.dll'%20or%20one%20of%20its%20dependencies.%20The%20given%20assembly%20name%20or%20codebase%20was%20invalid.%20(Exception%20from%20HRESULT%3A%200x80131047)%3CBR%20%2F%3EFile%20name%3A%20'MyProvider.dll'%3CBR%20%2F%3E%20at%20System.Reflection.AssemblyName.nInit(RuntimeAssembly%26amp%3B%20assembly%2C%20Boolean%20forIntrospection%2C%20Boolean%20raiseResolveEvent)%3CBR%20%2F%3E%20at%20System.Reflection.RuntimeAssembly.CreateAssemblyName(String%20assemblyString%2C%20Boolean%20forIntrospection%2C%20RuntimeAssembly%26amp%3B%20assemblyFromResolveEvent)%3CBR%20%2F%3E%20at%20System.Activator.CreateInstance(String%20assemblyString%2C%20String%20typeName%2C%20Boolean%20ignoreCase%2C%20BindingFlags%20bindingAttr%2C%20Binder%20binder%2C%20Object%5B%5D%20args%2C%20CultureInfo%20culture%2C%20Object%5B%5D%20activationAttributes%2C%20Evidence%20%3CBR%20%2F%3EsecurityInfo%2C%20StackCrawlMark%26amp%3B%20stackMark)%3CBR%20%2F%3E%20at%20System.Activator.CreateInstance(String%20assemblyName%2C%20String%20typeName)%3CBR%20%2F%3E%20at%20OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.GetProviderInstance(ExtensibilityHandler%20handler)%3CBR%20%2F%3E%20at%20OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.ExecuteExtensibilityExtractionCallOut(ClientContext%20ctx%2C%20ExtensibilityHandler%20handler%2C%20ProvisioningTemplate%20template%2C%20%3CBR%20%2F%3EProvisioningTemplateCreationInformation%20creationInformation%2C%20PnPMonitoredScope%20scope)%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-145803%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145803%22%20slang%3D%22en-US%22%3E%3CP%3EWell%20as%20far%20as%20i%20know%20the%20schema%20is%20published%20but%20is%20not%20supported%20in%20the%20code%20yet%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-145796%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145796%22%20slang%3D%22en-US%22%3E%3CP%3EReally%3F%20hmm...%20I%20looked%20at%20their%20GitHub%20page%20and%20it%20shows%20201801%20as%20an%20approved%20version.%20That%20said%2C%20I'll%20try%20201705%20tomorrow%20when%20I%20get%20back%20into%20the%20job%20to%20make%20sure.%20I'll%20report%20back%20then.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-145775%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisioning%20Engine%20Extensibility%20Handlers%3A%20FileLoadException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145775%22%20slang%3D%22en-US%22%3E%3CP%3EI%20think%20it%20is%20caused%20by%20the%20schema%20you%20are%20trying%20to%20use.%20i%20thought%20the%20201801%20would%20be%20available%20starting%20in%20februari.%20try%20201705%3C%2FP%3E%3C%2FLINGO-BODY%3E
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

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

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.

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

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

 

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