Community Forums
Results 1 to 4 of 4

Thread: How to call a .Net dll and recieve a string list

  1. #1
    Join Date
    Jul 2006
    Posts
    5

    How to call a .Net dll and recieve a string list

    i have managed to create and use a .net dll to add some functionality to the installer, but only managed to do get primitive types (including string) back from the function call.
    i need to get a string list, does anyone knows how can i achive this?

  2. #2
    Join Date
    Oct 2001
    Location
    Here and there
    Posts
    16,243
    I don't know enough about .NET string lists for a direct approach. If nothing else, your DLL can combine the strings with a delimiter ("one+two+three+etc.") and pass the big string back to InstallScript; InstallScript can then call StrGetTokens with your delimiter to create an InstallScript string list...

  3. #3
    Join Date
    Jul 2003
    Location
    Austin, TX
    Posts
    4,430
    Is this what you had in mind?

    http://chrpai.blogspot.com/2006/08/m...ectdotnet.html

    The trick is to exploit Interop to create a COM representation of the .Net object then pass it back to the managed code environment.

    Try this:

    InstallScript:

    Code:
    function MyFunction(hMSI)
    
     OBJECT colors;
     OBJECT customaction;
    
    begin
    
     set colors = CoCreateObject( "System.Collections.ArrayList");
    
     colors.Add( "RED" );
     colors.Add( "WHITE" );
     colors.Add( "BLUE" );
    
     set myObject = CoCreateObjectDotNet("C:\\customaction.dll", "customaction.MyClass" );
    customaction.MyMethod( colors);
    
    end;
    C#

    Code:
    using System;
    using System.Runtime.InteropServices;
    using System.Collections;
    using System.Collections.Generic;
    using System.Windows.Forms;
    
    namespace customaction
    {
     public class MyClass
     {
      public void MyMethod( ArrayList colors )
      {
       foreach( string color in colors )
       {
        MessageBox.Show( color );
       }
      }
     }
    }
    Christopher Painter
    ISWIX, LLC.
    Visit iswix.com for contact information

  4. #4
    Join Date
    Jul 2006
    Posts
    5

    Smile

    Wow, this is a neat trick, did not thought of creating built-in .net objects and pass them back and forth. (Of course this can be converted to Install Shield structures which was my initial intent).
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •