简体   繁体   English

PHP COM和C#“ Out”和布尔参数

[英]PHP COM and C# “Out” and boolean Parameters

I'm connecting through PHP "COM" to an API that is compatible with C#,C++ etc. I have successfully made connection with the application and trying to use "out" parameters through COM and getting a "type mismatch" error. 我正在通过PHP“ COM”连接到与C#,C ++等兼容的API。我已成功与该应用程序建立连接,并尝试通过COM使用“ out”参数并收到“类型不匹配”错误。 Is the "out" parameter and is supposed to house the response and then the false. 是“ out”参数,应该包含响应,然后为false。 I'm not sure if it fails on that or if it fails on the false.. but either way I can't get this to work. 我不知道它是否失败,或者它是否失败,但是无论如何我都无法正常工作。

the C# example looks like this: C#示例如下所示:

EdmViewInfo[] Views = null;
vault.GetVaultViews( out Views, false );

the php code looks like this: php代码如下所示:

$this->epdm = new COM('ConisioLib.EdmVault') or die("Cannot open vault.");

...

$this->aviews = array();      
try {

         $this->epdm->GetVaultViews($this->aviews, False );

   } catch (Exception $e) {

        echo 'Caught exception: ',  $e->getMessage(), "\n";

 }

I get the following returned errors: Caught exception: Parameter 1: Type mismatch. 我收到以下返回的错误:捕获的异常:参数1:类型不匹配。

Hope someone can help! 希望有人能帮忙!

I'm not intimately familiar with PHP's COM extension, but I did some research online that suggests to use COM [out] parameters in PHP you use the & operator so PHP uses pass-by-reference semantics: 我对PHP的COM扩展并不十分熟悉,但是我在线进行了一些研究,建议在PHP中使用&运算符使用COM [out]参数,以便PHP使用按引用传递语义:

$arr = array();
$com = new COM( 'ConisioLib.EdmVault' ) or die( "Cannot open vault." );
$com->GetVaultViews( &$arr, false );

Note that even though $arr would be completely overwritten by the [out] parameter you still need to initialize $arr to a native PHP array type so the COM marshalling layer knows what types its dealing with. 请注意,即使$arr[out]参数完全覆盖,您仍然需要将$arr初始化$arr本地PHP array类型,以便COM编组层知道其处理的类型。

It appears the two 'Array' types you are referencingf are not the same. 似乎您要引用的两种“数组”类型不相同。 ONe has a capital letter and the other does not. 只有一个大写字母,另一个没有。 IN addition, what you reference as a C# example, looks more like VB.NET. 另外,您引用的C#示例看起来更像VB.NET。 It may be best to check the case of all your references to Array to make sure they are found. 最好检查所有对Array的引用的大小写,以确保找到它们。 What editor are you using? 您正在使用什么编辑器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM