我有一个 Powershell 脚本,它调用 C# 库中的一个方法.库 dll 加载为:
I have a Powershell script that calls a method in a C# library. The library dll is loaded as:
[Reflection.Assembly]::LoadFrom("$automationHomedllabc.dll") | Out-Null现在,我的 C# 库在其中使用了另一个库 xyz.dll.我相信我不需要在 Powershell 脚本中加载它,因为 abc.dll 会解决它.但是,我收到一条错误消息:
Now, my C# library uses another library xyz.dll in it. I believe I don't need to load this in Powershell script, since the abc.dll will resolve it. However, I am getting an error saying:
无法加载文件或程序集 'xyz,版本 = 1.0.0.0,Culture=neutral, PublicKeyToken=null' 或其依赖项之一.这系统找不到指定的文件.
Could not load file or assembly 'xyz, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
谁能告诉我如何解决这个问题?
Can someone please tell me how to fix this?
推荐答案LoadFrom() 最好在 所在的目录中查找 xyz.dllabc.dll
LoadFrom() should ideally look for the xyz.dll in the same directory as abc.dll
如果您从与 dll 相同的目录运行脚本,请添加以下内容,然后执行 LoadFrom()
If you are running the script from the same directory as the dlls, add the below and then do the LoadFrom()
$currentScriptDirectory = Get-Location [System.IO.Directory]::SetCurrentDirectory($currentScriptDirectory.Path)更多推荐
Powershell dll加载
发布评论