AlexGomez
AlexGomez

Reputation: 51

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

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

Upvotes: 5

Views: 3737

Answers (1)

stej
stej

Reputation: 29449

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

Upvotes: 1

Related Questions