Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host

狂风中的少年 提交于 2019-12-23 12:57:13

问题


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: 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()


回答1:


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



来源:https://stackoverflow.com/questions/2849410/cannot-load-windows-powershell-snap-in-microsoft-powershell-host

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!