"An error occurred while loading the Windows PowerShell snap-ins.",

Trying to execute powershell script in my c # code. Using the .NET Framework v. 4.0.30319 SP1Rel in VS 2010 on Windows 7.

I have the following dll file as a link:

C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ WindowsPowerShell \ v1.0 \ system.management.automation.dll

And I include:

using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

Then, when I run the following commands:

RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); // here
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);

It crashes on the first line with the following exception:

{"An error occurred when loading the system Windows PowerShell snap-ins. Please contact Microsoft Support Services."}

Internal exception:

{"Unable to access Windows PowerShell PowerShellEngine registry information."}

"Powershell.exe" ( 2 1) cmd, , , . (http://social.msdn.microsoft.com/Forums/eu/biztalkesb/thread/a807bee7-531a-4990-b8da-47a7e6e3e099), . , , . !

+5
1

powershell v2, :

"echo ([PSObject].Assembly.Location)"

dll.

+3

All Articles