无法加载Windows PowerShell管理单元Microsoft.PowerShell.Host [英] Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host

查看:491
本文介绍了无法加载Windows PowerShell管理单元Microsoft.PowerShell.Host的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm attempting to invoke Windows Powershell cmdlets via Visual Studio .NET. However, I'm getting the exception shown below when I try to call a function.The Microsoft.PowerShell.ConsoleHost.dll wasn't initially in that path so I copied it over from another location. Is this the right way of installing a snap-in? It still spits out that exception and I'm not sure why. Any nudges in the right direction would be very helpful. Thanks.

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.PSSnap (PSSnapInInfo mshsnapinInfo)
在System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection`1 mshsnapinInfos,PSConsoleLoadException&警告)
在System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration() $ b,位于System.Management.Automation.Runspaces.RunspaceConfiguration.Create()

System.Management.Automation.Runspaces.PSSnapInException: Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host because of the following error: Could not load file or assembly 'file:///C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell.ConsoleHost.dll' or one of its dependencies. The system cannot find the file specified. System.Management.Automation.Runspaces.PSSnapInException: at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection`1 mshsnapinInfos, PSConsoleLoadException& warning) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration() at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()

推荐答案

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

Try to use fuslogvw tool provided by MS. It helps in such problems, when some assemblies can not be loaded.

这篇关于无法加载Windows PowerShell管理单元Microsoft.PowerShell.Host的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆