我需要为我的经典asp创建一个com对象。由于我可以创建一个.net程序集并使其与com“Interop”,因此我按照以下方式创建了一个.net程序集:
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web;
namespace LMS
{
[ComVisible(true)]
public class Calc
{
public int Add(int val1, int val2, out string[] outputz)
{
int total = val1 + val2;
outputz = new string[5];
outputz[1] = "test2";
outputz[2] = "test3";
outputz[3] = "test4";
outputz[4] = "test5";
return total;
}
}
}
接下来我做了通常的操作,构建并运行:gacutil & RegAsm
在我的经典asp页面中,我有以下内容:
Dim params
dim objPassport3
set objPassport3 = Server.CreateObject("LMS.Calc")
comTest2 = objPassport3.Add(1,1,params)
我遇到了错误:
错误类型: Microsoft VBScript runtime (0x800A0005) 无效的过程调用或参数:'Add' /eduservice/test.asp,第25行
但是如果我修改程序集不使用数组,它就可以正常工作,我甚至可以在程序集和经典asp之间发送普通字符串或整数。 我阅读了很多东西,但是仍然出现同样的错误。
如果有人尝试过并且成功,请分享您的解决方案。
谢谢