Use non-GAC assembly for provisioning engine's ExtensibilityHandlerObject

Copper Contributor

Hello,

I'm trying to use New-PnPExtensbilityHandlerObject to add an extension to the provisioning engine.

 

When providing an assembly which is not installed in the GAC, it fails when using the New-PnPExtensbilityHandlerObject command, and using this as ExtensibilityHandler for Apply-PnPProvisioningTemplate.

 

Is there any way to reference a non-GAC assembly for the provisioning engine?

2 Replies

I haven't tried it using PowerShell, but from c# code, you don't need to register the Assembly in the GAC. Are you specifing the FQN of the Assembly? you know, something like:

Contoso.Project.MyCustomExtensibilityHandler, Contoso.Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

PnP Code is just using the System.Activator class to load the Assembly

var _instance = Activator.CreateInstance(handler.Assembly, handler.Type).Unwrap();

Here is more information about how the .net framework tries to load the assembly.

 

 

Hi Luis,

Indeed, from C# code this is perfectly possible - since the runtime base dir is set to the current bin/Debug folder for example. However, when using Powershell, the DLL resolution is looking in these directories:

file:///C:/Users/sevensn/Documents/WindowsPowerShell/Modules/SharePointPnPPowerShellOnline/2.15.1705.0

file:///C:/Windows/System32/WindowsPowerShell/v1.0/

 

I've tried changing these working directories in many ways, but got nothing to work.