使用COM将C#中的数组返回到Classic ASP

iKo*_*ode 4 c# asp.net com asp-classic

我试图使用com将数组从c#返回到经典的asp.这篇文章对我很有帮助,但我仍有问题:

我在c#中有以下方法:

public object[] returnStuff () {
    return new object[] {'1','2','3'};
}
Run Code Online (Sandbox Code Playgroud)

我的经典ASP:

dim responseArray1

responseArray1 = RegusSoapComponent.returnStuff()

response.write("Type of Array one is " & VarType(responseArray1))
response.write("Type of Array one is " & responseArray1(1))
Run Code Online (Sandbox Code Playgroud)

我的输出是:

response is Type of Array one is 8204
Run Code Online (Sandbox Code Playgroud)

Microsoft VBScript运行时错误"800a01ca"

变量使用VBScript中不支持的自动化类型

无论我做什么,我似乎都无法访问这个变量.

pat*_*yts 5

VBScript喜欢接收包含变体safearray的变体.因此,您需要返回一个包装对象数组的对象.例如:

public object returnStuff() {
    return new object[] {'1','2','3'};
}
Run Code Online (Sandbox Code Playgroud)

哪个应该以正确的方式进行编组.有关详细版本,请参阅上一个答案.