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

  • Thread starter Gustavo Monteiro
  • Start date
G

Gustavo Monteiro

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.CreateObject("MyObject")
Call myObj.Log(strArray)
Set myObj = Nothing

Thanks in advance,
Gustavo
 
J

Jeroen Mostert

Gustavo said:
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(UnmanagedType.SafeArray, SafeArraySubType =
VarEnum.VT_VARIANT), In] int[,] x);
}

Or this:

void Log([MarshalAs(UnmanagedType.SafeArray, In] Array x);

(I can't try it myself.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top