Exchange 2010 application on Visual Studio 2012 (.NET 4.0): Cannot load Exchange powershell snap-in: The type initializer for 'Microsoft.Exchange.Data.*' threw an exception

Hi

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

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

I am unable to understand the cause of the problem. But with reference to the this article, I have concluded that this is a bug. Please suggest the soultion. 
Thanks in a

March 25th, 2013 10:51am

Hello,

You should not use the dotnet 4.0 for a projet with Exchange 2013/2010/2007 component (specialy for the powershell addons not working with .net 4).

As you can see below the supported version are not including version higher than 3.5 on Exchange 2007

.NET Framework Exchange 2013 SP1 or later Exchange 2010 SP3 Exchange 2007 SP3

.NET Framework 2.0 SP1

 

 

X

.NET Framework 3.0

 

 

X

.NET Framework 3.5

 

X2

X1

.NET Framework 3.5 SP1

 

X

X

.NET Framework 4.0

 

X2,3

 

.NET Framework 4.5

X

X2,3

 

.NET Framework 4.5.1

X

 

 

.NET Framework 4.5.2

X

 

 

Source : https://technet.microsoft.com/en-us/library/ff728623%28v=exchg.150%29.aspx

You could code your application in a different way for doing this in .NET 4.0 using remote powershell and import the remote PSSession (same procedure used for remote powershell on exchange online).

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://exchangeserverfqdn.local/powershell/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Create a class that connect to the exchange server and invoke a remote pssession it should be working and adapt the cmdlet to the correct exchange version (should work for EX7/10/13 and higher version).

Have fun :)


Free Windows Admin Tool Kit Click here and download it now
June 11th, 2015 4:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics