Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:54:53+00:00 2026-06-05T18:54:53+00:00

Trying to execute powershell script in my C# code. Using .NET Framework v. 4.0.30319

  • 0

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

I have the following dll file as reference:

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."}

Inner exception:

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

I am able to run “Powershell.exe” (version 2 or 1) in cmd and it works fine and my project compiles as it should. I read this question (http://social.msdn.microsoft.com/Forums/eu/biztalkesb/thread/a807bee7-531a-4990-b8da-47a7e6e3e099) where they talked about some reg. keys but he forgot to mention exactly what he did to fix it. Really appreciate any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:54:55+00:00Added an answer on June 5, 2026 at 6:54 pm

    I opened a terminal and ran powershell v2 and then I ran the following command:

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

    which will give you the correct path to the dll being used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to execute a powershell script located at a remote machine using the
I'm trying to execute an EXE file using a PowerShell script. If I use
I'm trying to execute a command using the following code snippet: foreach($package in (Get-Childitem
trying to execute the stored proc in EF using the following code: var params
I have 2 powershell scripts that I execute from c# which I'm using to
Trying to execute a Powershell cmdlet from a MVC 3 Controller using impersonation but
I'm trying to write a PowerShell script that will do the following: Executes a
I'm trying to write a powershell script which will execute sqlcmd.exe to run a
I'm a Powershell newbie, trying to get a simple script to run. I have
I am trying to execute a TCL script from PHP. I am using PHP's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.