0

I have recently upgraded my application from .NET framework 2.0 to .NET 4.0. I am facing a strange problem after upgrade. I am unable to load Microsoft Exchange/Powershell Assemblies.

rc = RunspaceConfiguration.Create(); warning = null;
 if (Version == "2010") 
info = rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010", out warning);

One of the exceptions are:

[Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.][1]

The code works absolutely fine in .NET 2.0. I am unable to understand the cause of the problem. But with reference to this article,I have concluded that this is a bug. Please suggest the soultion.

Thanks in advance

Rizwan Ahmed
  • 81
  • 2
  • 8

1 Answers1

0

I think that you may be encountering the same issue as:

Cannot load Exchange powershell snap-in: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception

Do you have .NET 4.5 installed? It apparently overwrites .NET 4.0 and causes issues with the Exchange cmdlets. The above post fixed the issue by uninstalling .NET 4.5 and installing .NET 4.0.

Hope this helps!

Community
  • 1
  • 1
Briggs
  • 490
  • 1
  • 4
  • 10