开发者

return Array from C# to Classic ASP with COM

I am trying to re开发者_如何转开发turn an array from c# to classic asp using com. This post helped me lot, but I still have problems:

I have the following method in c#:

public object[] returnStuff () {
    return new object[] {'1','2','3'};
}

My classic ASP:

dim responseArray1

responseArray1 = RegusSoapComponent.returnStuff()

response.write("Type of Array one is " & VarType(responseArray1))
response.write("Type of Array one is " & responseArray1(1))

My output is:

response is Type of Array one is 8204

Microsoft VBScript runtime error '800a01ca'

Variable uses an Automation type not supported in VBScript

No matter what I do, I don't seem to be able to access this variable.


VBScript likes to receive a variant containing a safearray of variants. So you need to return an object wrapping your array of objects. eg:

public object returnStuff() {
    return new object[] {'1','2','3'};
}

which should get marshalled the right way. See a previous answer for the detailed version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜