How to pass an array to .NET assembly from VBScript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gustavo Monteiro

    How to pass an array to .NET assembly from VBScript?

    Hi,

    I've writen a class library in C# and intend to use it from an ASP page. It's not the first time I do it, so I already know the drill. This time however I'm trying to pass a two dimensional array of strings which I've never done before. I've tryed all sorts of types: string[,], object[,], object, Array. None of them work.

    Here is a sample code:

    Dim strArray(2, 2)
    strArray(0,0) = "col1"
    strArray(0,1) = "val1"
    strArray(1,0) = "col2"
    strArray(1,1) = "val2"
    Dim myObj
    Set myObj = Server.CreateOb ject("MyObject" )
    Call myObj.Log(strAr ray)
    Set myObj = Nothing

    Thanks in advance,
    Gustavo
  • Jeroen Mostert

    #2
    Re: How to pass an array to .NET assembly from VBScript?

    Gustavo Monteiro wrote:
    I've writen a class library in C# and intend to use it from an ASP page. It's not the first time I do it, so I already know the drill. This time however I'm trying to pass a two dimensional array of strings which I've never done before. I've tryed all sorts of types: string[,], object[,], object, Array. None of them work.
    >
    Did you use MarshalAs explicitly? In other words, have you tried this?

    public interface IMyObj {
    void Log([MarshalAs(Unman agedType.SafeAr ray, SafeArraySubTyp e =
    VarEnum.VT_VARI ANT), In] int[,] x);
    }

    Or this:

    void Log([MarshalAs(Unman agedType.SafeAr ray, In] Array x);

    (I can't try it myself.)

    --
    J.

    Comment

    Working...