O R G A N I C / F E R T I L I Z E R: error when using add-type with microsoft.exchange.webservices.dll

Jul 6, 2012

error when using add-type with microsoft.exchange.webservices.dll

yesterday, I was goofing around w/ the ews dll trying to use it to retrieve some information from exchange. well, I got it working on my laptop but could not get it working on my other two systems which kept erring out with the following message:

[3] {C:\temp} > Add-Type -Path "c:\temp\Microsoft.Exchange.WebServices.dll"
Add-Type : Could not load file or assembly
'file:///c:\temp\Microsoft.Exchange.WebServices.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Add-Type -Path "c:\temp\Microsoft.Exchange.WebServices.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.

after a few unsuccessful iterations of stupidity, I examined the configuration:

  • working system
    • windows 8
    • powershell v3
    • framework 4.5
  • non-working system
    • windows 7
    • powershell v3
    • framework 4.0

I talked to jonathan walz about it for a short spell because I didn't want to believe the framework was the issue even though I saw a few posts referencing security and opening things up in with caspol and things like that. anyway, it was a partially educated guess and other parts having nothing left to try... but as you've probably already figured out, loading framework 4.5 rc fixed it.