2009-08-31 9 views
6

私は、.NETアセンブリを作成してcomと 'Interop'を作成できるので、クラシックasp用のcomオブジェクトを作成する必要があります。このように.NETアセンブリを作成するには: -COM Interop(従来のASP経由で配列を渡す方法)

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; 
    } 


} 
} 

次の私はいつものをやった、構築、実行しました:&ます。regasm

ます。gacutilと私の従来のASPページに、私はこのいた: -

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

をしかし、私は、配列を使用しないようにアセンブリを変更した場合、それはすべてがうまく動作し、私も通常の文字列を送信したりすると、従来のASPへのアセンブリからint型することができます。 私はたくさんのことを読んで、私は同じエラーを取得し、

誰もが前にこれを試して、成功した、あなたのソリューションは、ASPが唯一のバリアントている配列を扱うことができる

答えて

9

感謝を共有する、というよりください文字列またはintの配列だから、返信用

public int Add(int val1, int val2, out object outputz) 
{ 
    int total = val1 + val2; 
    outputz = new object[5] 
     { 
      "test1", 
      "test2", 
      "test3", 
      "test4", 
      "test5" 
     }; 

    return total; 
} 
+0

感謝そんなに、例えば、代わりにオブジェクトを使用してみてください...状況 – visual

+0

OrbManであなたを更新try..willするカント待機が、おかげで、あなたは、私の問題を解決し、私は扱うことがしたいですあなたは昼食のために。 – visual

+0

プロンプトなし、喜んで助けてください。 – RedFilter

関連する問題