Results 1 to 3 of 3

Thread: Load FORM dymanic from DLL (Solved)

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2003
    Location
    Amsterdam, Holland
    Posts
    36

    Exclamation Load FORM dymanic from DLL (Solved)

    Hi All,

    With the following code I load a form dynamic form a DLL.
    The procedure works fine, but the problem is that I can only load forms
    without input parameters.
    I tryed a few things, but I don't know how the resolve this,
    (Is there a solution for ????)

    Can somebody help me.

    Thanks in advanced,

    AXH


    VB Code:
    1. Dim Type As String = "<dllname>.<formname>"
    2. Dim asmAssemblyContainingForm As [Assembly] = [Assembly].LoadFrom(<dllname>.dll)
    3. Dim typetoload As Type = asmAssemblyContainingForm.GetType(Type)
    4. Dim GenericInstance As Object
    5. GenericInstance = Activator.CreateInstance(typetoload)
    6. Dim frm As Form = CType(GenericInstance, Form)
    7. frm.ShowDialog()
    8. frm.Dispose()
    9. GC.Collect()
    Last edited by ahollaar; Apr 2nd, 2005 at 04:04 AM. Reason: Problem solved

  2. #2
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: Load FORM dymanic from DLL

    Assuming the contructor takes 1 string argument and 1 integer argument

    VB Code:
    1. Dim Type As String = "<dllname>.<formname>"
    2.         Dim asmAssemblyContainingForm As [Assembly] = [Assembly].LoadFrom("<dllname>.dll")
    3.         Dim typetoload As Type = asmAssemblyContainingForm.GetType(Type)
    4.         Dim GenericInstance As Object
    5.         Dim Arguments() As Object = {CType("Hello", Object), CType(132, Object)}
    6.         GenericInstance = Activator.CreateInstance(typetoload, Arguments)
    7.         Dim frm As Form = CType(GenericInstance, Form)
    8.         frm.ShowDialog()
    9.         frm.Dispose()
    10.         GC.Collect()
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2003
    Location
    Amsterdam, Holland
    Posts
    36

    Re: Load FORM dymanic from DLL (Solved)

    Thanks it's working.

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