cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jignesh_parikh
Level 4

Pass BYREF variable to .NET library from InstallShield

Hi,

I am trying to pass a reference string variable from installshield to a .net library method. Please have a look at below given code.

sDLL = SUPPORTDIR^LIBRARY_DLL;
UseDLL(sDLL);
set Lib = DotNetCoCreateObject(sDLL , "Library.TestClass", "");
//here the TestMethod will set the string1 and string2 after processing inputstring
nResult = Lib.TestMethod(inputstring, string1, string2);
UnUseDLL(sDLL);


but I am not getting strings back and string1 string2 remain empty. I read somewhere that calling .dll function by default pass the variables by reference.

Am I doing anything wrong? What is the right way to achieve this?

Regards,
Jigs
Labels (1)
0 Kudos
(2) Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

I am able to pass strings back from a method in a .NET assembly by using the 'out' modifier on the .NET method parameter, such as:
public void Test2(string sInput, out string sOutput)


The above method assigns a test string value to sOutput. When called from InstallScript, the string variable passed for the sOutput parameter receives the string value set by the .NET method.

Note that UseDLL should not be used with .NET assemblies. DotNetCoCreateObject is the only function call required to load a .NET assembly.
0 Kudos
jignesh_parikh
Level 4

Hi Josh Stechnij,

Thanks for your quick response. I appreciate.

I resolved the problem. Actually the problem found in my .NET library.

Regards,
Jigs
0 Kudos