Breaking change in 3.0 regarding COM interop/Excel automation - by wbradney

Status : 

 


2
0
Sign in
to vote
ID 774980 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 12/21/2012 12:23:03 PM
Access Restriction Public

Description

We have a Powershell script that automates Excel. It's been working fine in Powershell 2.0 for some time.
 
Recently our servers automatically updated the WMF and Powershell to 3.0, and lines like the following all started failing:

         $workbook.Application.Run("someFunc", [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing) 

with:

 Invoke-Command : Exception calling "Run" with "31" argument(s): "Invalid number of arguments." 

Note that this appears to be directly related to WMF 3 rather than the change from CLR 2.0 to 4.0:

On my WMF 2.0 test box I changed my powershell.exe.config to the following:
 
<configuration>
     <startup useLegacyV2RuntimeActivationPolicy="true">
         <supportedRuntime version="v4.0.30319"/>
     </startup>
 </configuration>
 
My theory is that now my Powershell 2.0 process can only load the 4.0 CLR (I confirmed that it indeed does load the 4.0 CLR), and my original script with 31 arguments should now fail in that shell.
 
In fact it works fine.




Sign in to post a comment.