cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Homawong
Level 2

How to get string array from .Net method in InstallScript

I have a method in .net with the following signature:

public long GetList(out string[] resultList){...}

How do I get the result in Install script?

I create the object using DotNetCoCreateObject() and call the method as follows:

function foo()
STRING resultList();
OBJECT dotNetObj;
NUMBER nResult;
begin
dotNetObj = DotNetCoCreateObject(...);
nResult = dotNetObj.GetList(resultList);
end;

the method returns but the resultList I got is always empty.

I tried with different Data Types: OBJECT, VARIENT, POINTER, LPSTR, LIST
all result in "parameter incorrect" exception.

if I pre-define the size of the string array: STRING resultList(5), the result is still empte array of size 5.

Thanks,
Homa Wong
Labels (1)
0 Kudos
(6) Replies
Not applicable

InstallScript string arrays are safe arrays, therefore you would probably have to change your COM object to interpret this as a safe array.

Devin Ellingson
Software Developer
Acresso Software
0 Kudos
Not applicable

You could also try GetCHARArrayFromISStringArray etc. to convert the array.

Devin Ellingson
Software Developer
Acresso Software
0 Kudos
Christopher_Pai
Level 16

This is an old article but you might want to check out:

http://blog.deploymentengineering.com/2006/08/more-fun-with-cocreateobjectdotnet.html

I don't really roll this way anymore though. I prefer to use DTF so that my C# code can simply interact with MSI properties with no code in the middle to drive it.
0 Kudos
Homawong
Level 2

Christopher Painter wrote:
This is an old article but you might want to check out:

http://blog.deploymentengineering.com/2006/08/more-fun-with-cocreateobjectdotnet.html

I don't really roll this way anymore though. I prefer to use DTF so that my C# code can simply interact with MSI properties with no code in the middle to drive it.


That sounds cool. What is DTF? Can you point me to some articles?


Thanks,
0 Kudos
Daniel_Dority
Level 6

Are you trying to throw the string array into a LIST object?

If so you, you can do it like this:


InstallShield

if(nDomainList <= 0) then
nDomainList = ListCreate(STRINGLIST);
endif;

StrGetTokens(nDomainList, Installer.GetStuff(), ",");


C#
[CODE]
private string ToStringList(ArrayList TargetList)
{
return String.Join(",", (string[])TargetList.ToArray(typeof(string)));
}
[/CODE]

In the case above, I joined an ArrayList into a single comma separated string and passed that back to InstallShield. You can modify the above to fit most collections and InstallShield uses them easily.
0 Kudos
Christopher_Pai
Level 16

Just google or search my blog for DTF ( Deployment Tools Foundation ) ... there's lot's of articles out there.
0 Kudos