1

我试图引用定义为的 COM 对象方法:

IEdmFile7::GetDerivedBOMs  
Returns the derived (a.k.a. "named" or "saved") bills of materials associated with this file.  
Prototype:

HRESULT GetDerivedBOMs( [out,ref] SAFEARRAY ( struct EdmBomInfo ) *ppoBoms );

我在 edmFile 变量中有对 IEdmFile7 对象的引用。

当我<cfdump var="#edmFile#">的方法是可见的:

Method: GetDerivedBOMs([out]USERDEFINED, [out, retval]VOID)

当我尝试调用该方法时(尝试传递许多不同的参数类型):

<cfset edmFile.GetDerivedBOMs(???)>

它与AutomationException: Member not found. 我只能假设它没有正确识别或投射参数。如何正确地将安全数组(结构)的引用传递给方法?

(根据评论编辑)

我尝试过的一些示例:

 <cfset myObject = createObject("java","java.lang.Object").init()> 
 <cfset myArray = arrayNew(1)> 
 <cfset myRefArrayOfObjects = javaCast("java.lang.Object[]", myArray)> 
 <cfset myResultArray = edmFile.GetDerivedBOMs(myRefArrayOfObjects)> 

结果:

 Member Not Found Description: Automation Exception: Member Not Found 

评论中的另一个尝试:

<cfset myArray = ArrayNew(1)> 
<cfset myArray = edmFile.GetDerivedBOMs()> 

结果:

There are no methods with the specified method name and argument types. 
Check your function and retry 
4

1 回答 1

1

不幸的是,这是一个 .net 互操作限制。来自 CF 文档

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13e1a-7fd4.html

  • 您不能使用指针作为参数或返回类型来调用方法。
  • 您不能调用带有 Out 参数的方法。

在这种情况下,您将使用 safearray 类型的变量的 byref 地址[指针] 来命中这两个变量,它将创建并作为 OUT 参数返回给您。

在这种情况下,我发现创建一个 .net 类来“包装”它来充当中介来解决 CF 在这样做时遇到的问题更容易。

于 2013-08-27T16:53:40.697 回答