[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Returning a multidimensional array to VBScript

Marc Vangrieken

11/16/2007 2:14:00 PM

Hi,

I need to write a ComVisible object in C# and there are some methods
that must return a multidimensional array of strings. I created a .NET
assembly, marked it COM visible, created a TLD via regasm and added
it to the GAC. I can now create instances and execute code, but I'm
not able to use the results that in the multidimensional array. I've
tries several version, but I can't get it to work.

Can someone help? I keep getting Type mismatch errors. A lot of this
is written on the Internet, but nothing seems to work.

//Version1
public string[][] ClientManagementQuery(bool CW_OPERATIONAL)
{
....
return ConvertDataToArray(orderedView); //
ConvertDataToArray returns string[][]
}

//Version2
public object[,] ClientManagementQuery(bool CW_OPERATIONAL)
{
...
return (object[,])ConvertDataToArray(orderedView);
}

//Version3
public object ClientManagementQuery(bool CW_OPERATIONAL)
{
...
return (object)(object[,])ConvertDataToArray(orderedView);
}

Here's the VBScript

Dim foo
Set foo = CreateObject("Genco2pi.Logic.Genco2piLogic")
dim results(1000,1000)
results = foo.ClientManagementQuery(true)
MsgBox results(1,1)

Thanks in advance,
Marc
1 Answer

Marc Vangrieken

11/20/2007 8:47:00 AM

0

On Nov 16, 3:13 pm, Marc Vangrieken <marc.vangrie...@gmail.com> wrote:
> Hi,
>
> I need to write a ComVisible object in C# and there are some methods
> that must return a multidimensional array of strings. I created a .NET
> assembly, marked it COM visible, created a TLD via regasm and added
> it to the GAC. I can now create instances and execute code, but I'm
> not able to use the results that in the multidimensional array. I've
> tries several version, but I can't get it to work.
>
> Can someone help? I keep getting Type mismatch errors. A lot of this
> is written on the Internet, but nothing seems to work.
>
> //Version1
> public string[][] ClientManagementQuery(bool CW_OPERATIONAL)
> {
> ....
> return ConvertDataToArray(orderedView); //
> ConvertDataToArray returns string[][]
> }
>
> //Version2
> public object[,] ClientManagementQuery(bool CW_OPERATIONAL)
> {
> ...
> return (object[,])ConvertDataToArray(orderedView);
> }
>
> //Version3
> public object ClientManagementQuery(bool CW_OPERATIONAL)
> {
> ...
> return (object)(object[,])ConvertDataToArray(orderedView);
> }
>
> Here's the VBScript
>
> Dim foo
> Set foo = CreateObject("Genco2pi.Logic.Genco2piLogic")
> dim results(1000,1000)
> results = foo.ClientManagementQuery(true)
> MsgBox results(1,1)
>
> Thanks in advance,
> Marc

Ok, for some reason version 3 is working now. I think I was mixing
different versions of DLL's, only re-registering some of them.