无法加载文件或汇编(DLL文件路径 名称)或其依赖项之一.尝试使用不正确的格式加载程序



尝试执行 -

Import-Module 'C:\Program Files\Nimble Storage\bin\Nimble.Powershell.dll'

通过程序,我将收到以下错误:

无法加载文件或汇编'文件:///C: Program Files Nimble 存储 bin nimble.powershell.dll'或其依赖项之一。一个 试图加载具有不正确格式的程序。

直接从PowerShell跑时,同样的工作,但在上述情况下,面临问题。

C#程序使用并使用了语句:

Collection< PSObject > resultCollection = runspaceInvoke.Invoke("Import-Module 'C:\Program Files\Nimble Storage\bin\Nimble.Powershell.dll'", null, out errors);

ebgreen是正确的。需要查看您的代码兄弟。在没有此的情况下,类似以下内容应该有效:

using System.Management.Automation;
using System.Management.Automation.Runspaces;
class foo {
    static void Main(string[] args) {
        InitialSessionState initial = InitialSessionState.CreateDefault();
        initial.ImportPSModule(new string[] {"'C:\Program Files\Nimble Storage\bin\Nimble.Powershell.dll'"} );
        ...
    }
}

查看创建一个初始史塔特以获取更多信息。

最新更新