How can I load WPFToolkit assembly in Powershell
-
22-08-2019 - |
Question
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?
Solution
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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow