简体   繁体   中英

How can I load WPFToolkit assembly in Powershell

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM