PowerShell runtime exception - “could not load file or assembly”

后端 未结 5 1632
既然无缘
既然无缘 2021-01-11 11:27

This seems to be a common problem in PowerShell and Visual Studio, yet cases and solutions seem to vary a lot. Though seeing several similar questions, I didn\'t find a work

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-11 11:42

    I would look at WinSCP.dll dependencies in ILDASM or dotPeek and then load those dependencies before loading WinSCP.dll. The problem is that you are running in PowerShell.exe (or powershell_ise.exe) fusion load context and the assemblies that WinSCP.dll aren't going to be found under these two exe's base dirs. So you will need to load the dependent assemblies before the CLR loader chokes because it can't find a required DLL. If you need help figuring out which assembly can't be found, check out the fuslogvw.exe tool.

    BTW, as of PowerShell v2 you should use Add-Type -Path instead of [S.R.A]::LoadFrom(...).

提交回复
热议问题