Powershell dll加载

编程入门 行业动态 更新时间:2024-10-25 05:13:47
本文介绍了Powershell dll加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 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加载

本文发布于:2023-11-12 07:20:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   Powershell   dll

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!