php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26632 Problem calling COM interface methods
Submitted: 2003-12-15 12:18 UTC Modified: 2004-02-26 09:39 UTC
Votes:7
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:5 (71.4%)
Same OS:6 (85.7%)
From: Regis dot Derimay at iQvolution dot com Assigned: wez (profile)
Status: Closed Package: COM related
PHP Version: 5CVS OS: Windows XP Professional
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Regis dot Derimay at iQvolution dot com
New email:
PHP Version: OS:

 

 [2003-12-15 12:18 UTC] Regis dot Derimay at iQvolution dot com
Description:
------------
I call the following in PHP:
$x = new VARIANT(0.0, VT_R8 | VT_BYREF);
$y = new VARIANT(0.0, VT_R8 | VT_BYREF);
$z = new VARIANT(0.0, VT_R8 | VT_BYREF);
com_invoke($sphereIf, "getPosition", $x, $y, $z, false);

The getPosition function is defined by:
	interface IiQSphereObjIf : IDispatch
	{
		[id(1), helpstring("method getPosition")] HRESULT getPosition([out] double* x, [out] double* y, [out] double* z, [in] VARIANT_BOOL globalTrafo, [out, retval] int* result);
	};

I get the following error code
Warning: com_invoke(): Invoke() failed: Type mismatch. Argument: 2 in ...php

It seems to be a problem with the COM module when using functions with paramaters by reference (like x, y and z here).
When using normal parameters everything is working well.

Expected result:
----------------
Having x y and z filed with the position.

Actual result:
--------------
I get the following error code
Warning: com_invoke(): Invoke() failed: Type mismatch. Argument: 2 in ...php



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-16 03:04 UTC] Regis dot Derimay at iQvolution dot com
I forgot to say, that PHP 5 is crashing with this example.
 [2003-12-16 03:07 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Are you using the latest CVS snapshot..?
 [2003-12-16 03:57 UTC] Regis dot Derimay at iQvolution dot com
No I was not. Now I tested it.
It is still crashing, also in function in which it did not crash before (without use of references)
 [2003-12-16 04:36 UTC] wez@php.net
Please try it without the reference flags:

try {
  $x = new Variant(0.0);
  $y = new Variant(0.0);
  $z = new Variant(0.0);
  $sphere->getPosition($x, $y, $z, false);
}
catch (exception $e) {
  print_r($e);
}

If that doesn't work, can you please be more specific
about what is going wrong (does it crash or does it
throw an exception?).

Please also include details about the "function that
did not crash before (without the use of references)".

Ideally, I want to be able to reproduce this on my
machine here so I can debug it; is the component
you are using publically available? (source preferred).
 [2003-12-16 05:36 UTC] Regis dot Derimay at iQvolution dot com
Hi.

try and catch does not work. It still crash.
I will now try to reduce the source as much as possible to a few lines of codes so you can reproduce it.
The source code of our module is not available but I could send you the needed dll, so you can test it. To which email should I send the dlls?
 [2003-12-16 05:39 UTC] wez@php.net
Please send the dll to wez@php.net along with appropriate installation instructions and the smallest reproducing script.
 [2003-12-22 06:50 UTC] Regis dot Derimay at iQvolution dot com
Here the easiest script I got:
DLLs and needed instrcutions were sent by email the 16th dec. at 11:58 European time. (Subject DLLs for Bug #26632)
Hope this help. Would be nice to see this bug solved!

<?php
try {
    $iQlib = new COM("iQvolution.iQLibIf");

    $iQlib->load("c:\\A.iQmod");

	$numScans = $iQlib->getNumScans();
	echo "Nb of scans:{$numScans}<BR>\r\n";

	for($i = 0; $i < $numScans; $i++)
	{
		$objIf = $iQlib->getScanObject($i);
		$scanName = $objIf->getName();
		echo "&nbsp;&nbsp;Scan {$i}:&nsp;{$scanName}<BR>\r\n";

		$x = VARIANT(0.0, VT_R8 | VT_BYREF);
		$y = VARIANT(0.0, VT_R8 | VT_BYREF);
		$z = VARIANT(0.0, VT_R8 | VT_BYREF);
		$scanIf = $objIf->getScanObjSpecificIf();
		$scanIf->getPosition($x, $y, $z, false);
	}

//    $iQlib->Release();
    $iQlib = null;
}
catch (exception $e)
{
	echo "<PRE>";
	print_r($e);
	echo "</PRE>";
}
?>
 [2004-02-21 03:33 UTC] Regis dot Derimay at iQvolution dot com
Is someone working on this very anoying bug? Did not here anything since a while!

Thanks
 [2004-02-21 18:17 UTC] wez@php.net
Sorry, this report slipped through the cracks.
I did however add automatic support for byref
parameters, so the code below *should* work
(no need to explicitly create variant objects
for $x, $y, $z).

Please let me know how you get on; try a recent PHP 5
snapshot (code was added a little while ago; beta 4
should work).

iQlib = new COM("iQvolution.iQLibIf");
$iQlib->load("c:\\A.iQmod");
$numScans = $iQlib->getNumScans();
for($i = 0; $i < $numScans; $i++) {
   $objIf = $iQlib->getScanObject($i);
   $scanIf = $objIf->getScanObjSpecificIf();
   $scanIf->getPosition($x, $y, $z, false);
}


 [2004-02-22 04:17 UTC] Regis dot Derimay at iQvolution dot com
Hi! Thanks for the answer.
Now I am using PHP 5 beta 4. I use the php-cgi.exe version.

I'm doing the following:
<?php 
	echo "Start";

try {
	$iQlib = new COM("iQvolution.iQLibIf");
}
catch (exception $e)
{
	echo "<PRE>";
	print_r($e);
	echo "</PRE>";
}

echo "End";
?>

It crashs echoing the following:
Start
com_exception Object
(
    [message:protected] => Failed to create COM object `iQvolution.iQLibIf': The specified module could not be found.

    [string:private] => 
    [code:protected] => -2147024770
    [file:protected] => C:\Documents and Settings\rd\My Documents\iQvolution\Develop\iQworks HTML\Debug\iQworks\ProjectManagement\COM.php
    [line:protected] => 5
    [trace:private] => Array
        (
        )

)

End


Of course, it seems as the iQworks COM Obj is not registered, but this is not true as for example Excel with a visual basic script is working correctly.

Do you want me to send you the dlls? Or do something that could help to debug the problem?

Thanks!

R?gis
 [2004-02-22 04:53 UTC] Regis dot Derimay at iQvolution dot com
Ok. Here the previous problem:
I registered the iQopen.dll (COM) using regsvr32 on a path defined with a subst. The dos "subst" command allows to define a virtual harddrive under windows. Interesting enough, if you register your COM using a path based on a subst, PHP is not able to find the module (error of the previous message). But other tools like Excel are able to do it.
So maybe you want to take a look on this.

Now I am able to load the initial script under PHP 5 beta 4. I am doing the following:
<?php 
try {
	$iQlib = new COM("iQvolution.iQLibIf");

	$iQlib->load("c:\\A.iQmod");

	$numScans = $iQlib->getNumScans();
	echo "Nb of scans:{$numScans}<BR>\r\n";

	for($i = 0; $i < $numScans; $i++)
	{
		$objIf = $iQlib->getScanObject($i);
		$scanName = $objIf->getName();
		echo "&nbsp;&nbsp;Scan {$i}:&nbsp;{$scanName}<BR>\r\n";

		$scanIf = $objIf->getScanObjSpecificIf();
		$scanIf->getPosition($x, $y, $z, false);
		echo "$x";
	}

//    $iQlib->Release();
    $iQlib = null;
}
catch (exception $e)
{
	echo "<PRE>";
	print_r($e);
	echo "</PRE>";
}
?>

It crashing with a "memory could not be written" message. It displays
-------
Nb of scans:3
  Scan 0: 
-------

So basically the same as beta 3. How can we solve the problem ??
 [2004-02-22 05:20 UTC] wez@php.net
I'll look into it, but don't have time to get stuck in
for a couple of weeks :/

Note: the subst thing is due to security privilieges that
your web server is using at runtime.
 [2004-02-22 05:34 UTC] Regis dot Derimay at iQvolution dot com
Ok for the subst.
For the rest of a problem, that is of course a bad news for me that you you do not have time now because I presume that it could then be not solved in PHP 5 release version. :-( 
Is there anything I can do to help you save time??
 [2004-02-24 20:02 UTC] alain at samoun dot com
<?PHP

	$Vsheets1 = new VARIANT("", VT_BSTR); #No byRef - works
	$Vsheets2 = new VARIANT("", VT_BSTR|VT_BYREF); #Doesn't work
	
	
?>
 [2004-02-26 09:39 UTC] Regis dot Derimay at iQvolution dot com
Hi,

we found a bug in our COM-IF, which wrongly referenced one object. So in the most cases, unref was called on this object to early.
Sorry for that. You can close the case.

JFY, the following code does not work:
$scanIf->getPosition($x, $y, $z, false);

You have to define your vars before:
$x = 0.0;
$y = 0.0;
$z = 0.0;
$scanIf->getPosition($x, $y, $z, false);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC