"无效的过程调用或参数"调用sub时没有括号一个参数

时间:2017-10-17 11:24:04

标签: vb.net vbscript asp-classic pass-by-value comvisible

我用这段代码(VB.NET)编写了一个COM-Visible DLL

' .NET Class with implementing an interface to make it visible
Public Class VisibleClass
    Public Sub callableSub(ByVal names As ACustomCollection, _
                           Optional ByVal doSomething As Boolean = True) _
        Implements IVisibleClass.visibleCallableSub
        Me.doSub(names.process, doSomething)
    End Sub
End Class

' Interface for COM-visibility
<InterfaceType(ComInterfaceType.InterfaceIsDual)> _
Public Interface IVisibleClass
    Sub visibleCallableSub(ByVal names As ACustomCollection, _
                           Optional ByVal doSomething As Boolean = True)
End Interface

这里也是ASP网页创建对象并调用其方法:

' stuff.asp
Dim visibleObject
Dim aCustomCollection
Set visibleObject = getNewVisibleInstance (aCollection)
Set aCustomCollection = createEmptyCollection

aCustomCollection.add someStuffs
aCustomCollection.add otherStuffs
aCustomCollection.add lastStuffs

' These calls work:
visibleObject.visibleCallableSub(aCustomCollection)
visibleObject.visibleCallableSub(aCustomCollection), False
visibleObject.visibleCallableSub(aCustomCollection), True
Call document.fetchPropertyCollection ((properties), false)

' These ones don't:
visibleObject.visibleCallableSub someparams
visibleObject.visibleCallableSub someparams, False
visibleObject.visibleCallableSub someparams, True
Call document.fetchPropertyCollection (properties, false)

非工作电话会产生以下错误:

  

无效的过程调用或参数

我不明白为什么我必须加上括号。我知道这会告诉口译员在传递主题之前制作副本,但不是为什么它是强制性的。

注意:与此one相同的问题,即关于传递需要副本的引用的问题。然而,问题被告知是因为它传递了另一个函数的返回值&#34;,这使得通过研究更难实现。

1 个答案:

答案 0 :(得分:0)

如果被调用的子/函数要求(按),则无法传递引用(“指针”)。在参数周围加上'make a strong> copy '括号可确保被调用的Sub / Function获得

为了明确你的意图,你应该写:

<schema name="example-data-driven-schema" version="1.6">
    ...
    <field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
    <field name="thread_id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
    <field name="first_name" type="string_lowercase" indexed="true" stored="true"/>
    <field name="last_name" type="string_lowercase" indexed="true" stored="true"/>
    <field name="email" type="string_lowercase" indexed="true" stored="true"/>
    <field name="subject" type="string_lowercase" indexed="true" stored="true"/>
    <field name="html" type="string_lowercase" indexed="true" stored="true"/>
    ...
    <copyField source="first_name" dest="_text_"/>
    <copyField source="last_name" dest="_text_"/>
    <copyField source="email" dest="_text_"/>
    <copyField source="subject" dest="_text_"/>
    <copyField source="html" dest="_text_"/>
    ...
</schema>

比照。 same errorparenthesesadventures