views:

1090

answers:

1

I have installed WPF Toolkit:

Location: C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll 
Name: WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
Type: Library

I can load it by full path:

[System.Reflection.Assembly]::LoadFrom("C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll")

But can't load by assembly name:

[System.Reflection.Assembly]::LoadWithPartialName("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

[System.Reflection.Assembly]::Load("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

What is a solution?

+3  A: 

Loading by assembly name doesn't work because the WPFToolkit assembly is neither in GAC nor in the PowerShell directory. There are several options:

  • load it by path
  • add it to the GAC
  • change powershell.exe.config to look in the WPF Toolkit directory
  • handle the AppDomain.AssemblyResolve event (not particulary easy in PowerShell V1)
jachymko
I thought it was in the GAC (confused by VS "Add Reference" dialog).
alex2k8
yeah, the VS "Add Reference" dialog actually displays a registry-backed list of assemblies
jachymko
"handle the AppDomain.AssemblyResolve event (not particulary easy in PowerShell V1)"What about in Powershell V2?
jpierson