Results 1 to 2 of 2

Thread: VB Class Library launch

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2018
    Location
    Bosnia and hercegovina
    Posts
    5

    Lightbulb VB Class Library launch

    HI

    I have DLLs which have classes, in clases is methods for show forms.
    These dlls launches an exe project which is compiled, and few dlls calls another with code:

    Dim obj As New dllName.ClassName // via reference in VS
    obj.ShowMainForm ( testID, Username ... )


    or with create object:

    Dim obj As New Object
    obj = CreateObject("dllName.ClassName")
    obj.ShowMainForm



    Is there any way to make one universal dll launcher in vb or C#.
    I mean exe application, which loads dll, and shows classes, methods, and I select method from class, and set parammeters like up in example testId, Username......


    Any help will be good

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: VB Class Library launch

    Yeah, maybe...sort of. You can certainly do part of that using reflection. Here's a bit of code that opens dlls dynamically and looks at the types in the dll:

    Code:
    For Each fl As String In IO.Directory.GetFiles(dirLoc, "*.dll")
                    Try
                        Dim aDLL As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile(fl)
    
                        If aDLL IsNot Nothing Then
                            Dim tArr As Type() = aDLL.GetExportedTypes
    
                            For Each t As Type In tArr
    In that code, dirLoc is the directory that the code is looking at. It iterates through all .dll files in that directory. It then loads the file, then gets all public types in the dll. You'd be going one level deeper, because you'd be looking at the exposed methods within the types, whereas I'm just looking at the types themselves to see whether they implement certain interfaces (not shown, but just one line).


    So, you can certainly look at the types within a dll, and you can look at the methods in a type, but what you are thinking of doing after that is what I'm not so sure about. You do have to create an instance of the type, which isn't hard once you know the name (you already showed a way to do that), what you do beyond that...I'm not quite sure what you are wanting.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width