This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Pass BYREF variable to .NET library from InstallShield
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 22, 2010
01:56 AM
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.
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
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
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 22, 2010
02:13 PM
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:
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.
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 23, 2010
12:13 AM
Hi Josh Stechnij,
Thanks for your quick response. I appreciate.
I resolved the problem. Actually the problem found in my .NET library.
Regards,
Jigs
Thanks for your quick response. I appreciate.
I resolved the problem. Actually the problem found in my .NET library.
Regards,
Jigs
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)