简体   繁体   中英

C# remote (exchange)powershell

i made a while back an console application(in c#) which does a few powershell commands. i connect to the (exchange)powershell with remote powershell. but when the application runs;

RunspaceFactory.CreateRunspace(connectioninfo)

i get the following exception:

Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

the only thing i cannot figure out is why it was working before perfectly. i searched my solution, nowhere i could find a reference to that dll. i also searched my c# drive it was nowhere to be found either. i restored my solution from my backup of 2-3 months old and the same error. Can someone give me some pointers to what is going wrong?

Found the problem. apparently something is wrong on my computer(I'm guessing after installing the Beta of VS11)

anyhow, after using the project on a different machine where VS2010 is installed it worked just fine.

The error message is misleading.

I had got the error, as I used the reference to the System.Management.Automation.dll Version 3.0.0.0 (which means PowerShell 3.0).

The issue is, the Exchange Server 2007/2010 isn't compatible with PowerShell 3.0, so you must bind the reference to the System.Management.Automation.dll version 1.0.0.0 (Windows PowerShell 2.0).

  1. Check all project references
  2. Check app.config
  3. Have a look here

UPDATES

Have a look here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM