Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Loading and Unloading .dll file in C#

Loading and Unloading .dll file in C#

Scheduled Pinned Locked Moved C#
csharphelpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pakFari
    wrote on last edited by
    #1

    Hi, how can I load and unload a .dll file at runtime in my C# project. I need urgent reply plz help me. thankx

    E A 2 Replies Last reply
    0
    • P pakFari

      Hi, how can I load and unload a .dll file at runtime in my C# project. I need urgent reply plz help me. thankx

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      How do you need to load it? Do you need to read it or use it, if you need to use the .dll then there would be no point in unloading it.

      1 Reply Last reply
      0
      • P pakFari

        Hi, how can I load and unload a .dll file at runtime in my C# project. I need urgent reply plz help me. thankx

        A Offline
        A Offline
        amitmohanty
        wrote on last edited by
        #3

        http://www.c-sharpcorner.com/2/pr12.asp does this help?

        P 1 Reply Last reply
        0
        • A amitmohanty

          http://www.c-sharpcorner.com/2/pr12.asp does this help?

          P Offline
          P Offline
          pakFari
          wrote on last edited by
          #4

          thanks for u r help, actually i am doing the same thing as mentioned in www.c-sharpcorner.com/2/pr12.asp, through this way i have to explicitly add the .dll file (component)to my project(using add reference),but i want to add(load) that component at runtime. as we do in VC++.

          D 1 Reply Last reply
          0
          • P pakFari

            thanks for u r help, actually i am doing the same thing as mentioned in www.c-sharpcorner.com/2/pr12.asp, through this way i have to explicitly add the .dll file (component)to my project(using add reference),but i want to add(load) that component at runtime. as we do in VC++.

            D Offline
            D Offline
            DeepToot
            wrote on last edited by
            #5

            pakfari: Use Assembly to load the dll, like so: Assembly SampleAssembly; string fullp = ((Full Path to the dll)) SampleAssembly = Assembly.LoadFrom(fullp); //In order to create an Instance of it you have to grab the type of this class //use Namespace.ClassName Type ObjType = SampleAssembly.GetType(Namespace.ClassName); //Create an instance of your dll here Activator.CreateInstance(ObjType); As far as running the Dll, there are a few ways to do it. but this is how you would/could load it at runtime. Hope his helps Steve Welborn Software Architect

            P 1 Reply Last reply
            0
            • D DeepToot

              pakfari: Use Assembly to load the dll, like so: Assembly SampleAssembly; string fullp = ((Full Path to the dll)) SampleAssembly = Assembly.LoadFrom(fullp); //In order to create an Instance of it you have to grab the type of this class //use Namespace.ClassName Type ObjType = SampleAssembly.GetType(Namespace.ClassName); //Create an instance of your dll here Activator.CreateInstance(ObjType); As far as running the Dll, there are a few ways to do it. but this is how you would/could load it at runtime. Hope his helps Steve Welborn Software Architect

              P Offline
              P Offline
              pakFari
              wrote on last edited by
              #6

              I will just say Great!!! It is working ok, can u tell me one more thing. How we can invoke the member functions of the Component using objType.

              D 1 Reply Last reply
              0
              • P pakFari

                I will just say Great!!! It is working ok, can u tell me one more thing. How we can invoke the member functions of the Component using objType.

                D Offline
                D Offline
                DeepToot
                wrote on last edited by
                #7

                Well, this is where it can get tricky..at least for me. Because there are a few ways to do this, depending on if you want to call the function right then, or place that object in a Collections class and call it later. Hopefully someone will be able to explain it better than I can, but here goes. This is how I executed a .dll after loading it. Remember that when you created the Instance it passed back an object object instance; //what Assembly.CreateInstance returns object[] args; //Parameters to pass the function MethodInfo method = type.GetMethod(functionname); object returnval = method.Invoke(instance, args); I hope this helps. Steve Welborn Software Architect

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups