返回从C#数组到经典的ASP与COM [英] return Array from C# to Classic ASP with COM

查看:142
本文介绍了返回从C#数组到经典的ASP与COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从C#数组返回使用COM传统的ASP。 <一href=\"http://stackoverflow.com/questions/1356755/com-interop-how-to-pass-an-array-to-the-com-via-classic-asp\">This后帮了我很多,但我仍然有问题:

我在C#下面的方法:

 公用对象[] returnStuff(){
    返回新的对象[] {'1','2','3'};
}

我的传统的ASP:

 暗淡responseArray1responseArray1 = RegusSoapComponent.returnStuff()的Response.Write(阵列中的一个类型是与&amp; VarType函数(responseArray1))
回复于(阵列之一类型为与&amp; responseArray1(1))

我的输出是:

 的反应是数组类型之一就是8204


  

Microsoft VBScript运行时错误800a01ca


  
  

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


不管我做什么,我似乎不能够访问这个变量。


解决方案

喜欢的VBScript接收包含变体SAFEARRAY的变体。所以,你需要返回一个对象包装的对象数组。例如:

 公共对象returnStuff(){
    返回新的对象[] {'1','2','3'};
}

这应该得到编组的正确途径。见<一href=\"http://stackoverflow.com/questions/5079200/how-to-correctly-marshal-vb-script-arrays-to-and-from-a-com-component-written-in/5097474#5097474\">a previous答案的详细版本。

I am trying to return 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.

这篇关于返回从C#数组到经典的ASP与COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆