Sunday, January 19, 2014

Load .net 4 assembly in PowerShell

One thing I often do when I'm working with SharePoint is to reuse code that I have put in a assembly, e.g. a manager class that perform a task during deployment. In SharePoint 2010, I picked up assembly in PowerShell via the static method System.Reflection.Assembly.Load. This method loads a given assembly from the GAC. But in .Net 4 is the location of GAC moved to another location “%windir%\Microsoft.NET\assembly\”. This done that System.Reflection.Assembly.Load does not work anymore. Forward I will use System.Reflection.Assembly.LoadWithPartialName or PowerShell cmdlet add-type.

More information about the new CLR Binder can be found here

1 comment: