我需要为我的经典asp创建一个com对象,因为我可以创建一个.net程序集并将它与’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
Dim params dim objPassport3 set objPassport3 = Server.CreateObject("LMS.Calc") comTest2 = objPassport3.Add(1,1,params)
我得到错误:
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: ‘Add’
/eduservice/test.asp,line 25
但是,如果我修改程序集不使用数组,它只是工作,我甚至可以将正常的字符串或int发送到程序集和从程序集到经典的asp.
我读了很多东西,但我得到了同样的错误,
谢谢
解决方法
ASP只能处理变量的数组,而不是字符串或整数的数组.所以尝试使用对象,例如,
public int Add(int val1,out object outputz) { int total = val1 + val2; outputz = new object[5] { "test1","test2","test3","test4","test5" }; return total; }
原文地址:https://www.jb51.cc/csharp/239205.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。