WMF 5 - Invalid callee when using variant wrapper
If I use the Runtime.InteropServices.VariantWrapper in WMF5 I get errors trying to interact with the system center orchestrator 2012 com object.. (x86)
IE if I do this without WMF5:
$oisMgr = new-object -com OpalisManagementService.OpalisManager
$oHandle = New-Object Object
$handle = New-Object Runtime.InteropServices.VariantWrapper($oHandle)
$oisMgr.Connect($Username, $Credential.Password, [ref]$handle)
It works fine, if I run with WMF5 I get an Invalid Callee Error.
OS is windows 2012.. thinking about it as I write this, has the 'Object' type changed at all between the two?
To be honest PowerShell historically does not handle variants particularly well. We may have regressed in this area, which would be bad, so we have question and some pointers to articles that may help.
Can you give us the information in $PSVersionTable, please?
There is a good article in StackOverflow that talks about using Variants and offers some suggestions: http://stackoverflow.com/questions/30512785/retrieving-session-id-from-com-method
One of the better suggestions is in a link from that article: http://www.archivum.info/microsoft.public.windows.powershell/2010-01/00361/RE--quot-Invalid-callee-quot--calling-a-com-object.html. While the content is valuable, I will apologize in advance for the ad placement on that page :-(
Same problem here, also with Orchestrator...
David Wallis commented
I don't see anything of use in those articles.. the code in the method Connect-OrchestratorComInterface located here: https://github.com/davidwallis3101/OrchestratorCOM/blob/master/OrchestratorCOM.psm1
uses new-object to create an object to receive the handle - this works in wmf4 but not in v5..
I'm wondering still if I do a getType on $oHandle on wmf4 and 5 whether they are the same?
Is the variant wrapper part of powershell or .net?