【问题标题】:Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host无法加载 Windows PowerShell 管理单元 Microsoft.PowerShell.Host
【发布时间】:2010-05-18 04:23:43
【问题描述】:

我正在尝试通过 Visual Studio .NET 调用 Windows Powershell cmdlet。但是,当我尝试调用函数时,我遇到了下面显示的异常。Microsoft.PowerShell.ConsoleHost.dll 最初不在该路径中,因此我从另一个位置复制了它。这是安装管理单元的正确方法吗?它仍然吐出那个异常,我不知道为什么。朝着正确方向的任何推动都会非常有帮助。谢谢。

System.Management.Automation.Runspaces.PSSnapInException:由于以下错误,无法加载 Windows PowerShell 管理单元 Microsoft.PowerShell.Host:无法加载文件或程序集“file:///C:\Windows \System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.ConsoleHost.dll' 或其依赖项之一。该系统找不到指定的文件。 System.Management.Automation.Runspaces.PSSnapInException: 在 System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo) 在 System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo) 在 System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(集合`1 mshsnapinInfos,PSConsoleLoadException& 警告) 在 System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration() 在 System.Management.Automation.Runspaces.RunspaceConfiguration.Create()

【问题讨论】:

  • 恐怕不太清楚你在做什么。您能否至少提供一段实际导致该异常的代码块?

标签: powershell clr


【解决方案1】:

尝试使用MS提供的fuslogvw工具。当某些程序集无法加载时,它有助于解决此类问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 2013-08-22
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    • 2012-12-19
    • 1970-01-01
    相关资源
    最近更新 更多