Search

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

Active

2
0
Sign in
to vote
Type: Bug
ID: 774980
Opened: 12/21/2012 12:23:03 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
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.




Details (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

No, this is new to the most recent version
Reproduction Steps
On my test box I started out with Powershell 2.0, .NET 4.0 (courtesy of VS2010), Office 2010, and a working script with 30 [Type]::Missing arguments.

After KB2506143 (WMF 3.0) was applied (and only that update), the script fails.

Rolling back KB2506143 made the script work again.
Expected Results
KB2506143 should not have broken existing, working powershell scripts.
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.