SharePoint 2010, Powershell and BindingRedirects

Powershell is a great tool when working with SharePoint 2010!

However there is one thing to be wary of: BindingRedirects.

In SharePoint 2010 you probably used the following xml in a solution package:

<?xml version=”1.0″ encoding=”utf-8″?>
<Solution xmlns=”“>
<Assembly Location=”{YourDllName}.dll” DeploymentTarget=”GlobalAssemblyCache”>
<BindingRedirect OldVersion=”″/>

And your controls and code is updated from to the latest version (for example: in SharePoint 2010!

However! Not in Powershell!

So if you use powershell for example to create a number of sites based on a custom site defintion with for example custom provisioning code which still references the old version, that version, if it exists on the machine, is used or if it doesn’t exists throws the following error:

Could not load file or assembly ‘{YourDllName}, Version=, Culture=neutral, PublicKeyToken={PublicKeyToken}’ or one of its dependencies. The system cannot find the file specified.

You could solve this by editing/adding the powershell config file.

Powershell is located on 32-bit systems here is C:\Windows\System32\WindowsPowerShell\v1.0,
on 64-bit systems here C:\Windows\SysWOW64\WindowsPowerShell\v1.0.

Edit/Add the file powershell.exe.config and add the following (make sure to change these to the correct version numbers and make sure to add the correct assembly name and public key token):

<?xml version=”1.0″?>
<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″>
<assemblyIdentity name=”{YourDllName}” publicKeyToken=”{PublicKeyToken}” culture=”neutral” />
<bindingRedirect oldVersion=”″ newVersion=”″ />

Restart powershell and it should use the correct version.

One thought on “SharePoint 2010, Powershell and BindingRedirects

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: