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. WPF
  4. Dynamicly load DLL's

Dynamicly load DLL's

Scheduled Pinned Locked Moved WPF
questioncsharpwpf
3 Posts 3 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.
  • C Offline
    C Offline
    columbos14927
    wrote on last edited by
    #1

    Hey, Ive wrote a WPF application and now i wont to give a user the this feature: 1.User will write some DLL that will be based on WPF GUI. 2.When the user will ask my application to load his DLL my APP will load it and present it on the main window then user will work with it. 3.After he will finish to work with it he will ask to unload it. Question: 1.How it possible to write DLL with WPF GUI? 2.I dont know which DLL's will be so i need to load them dynamicly,how can i do this(maybe user have to implement some inteface in his DLL)?

    L D 2 Replies Last reply
    0
    • C columbos14927

      Hey, Ive wrote a WPF application and now i wont to give a user the this feature: 1.User will write some DLL that will be based on WPF GUI. 2.When the user will ask my application to load his DLL my APP will load it and present it on the main window then user will work with it. 3.After he will finish to work with it he will ask to unload it. Question: 1.How it possible to write DLL with WPF GUI? 2.I dont know which DLL's will be so i need to load them dynamicly,how can i do this(maybe user have to implement some inteface in his DLL)?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You should look into MEF[^] and Prism[^] Its not necessarily the easist thing to pick up on, but I would recomend reading through some of the stuff. This way you know what libraries are already out there and you do not re-invent the wheel. It is really easy to just load assembly.. But its the extending and such that will overwhelm you. That is when you will start to make your own patterns etc. (dont do that... Use what is out there). Here is out you load an assembly (and object)

      Assembly assembly = Assembly.LoadFrom("OtherLibrary.dll");
      Type type = assembly.GetType("EmbeddedObjectInOtherLibrary");
      object instanceOfMyType = Activator.CreateInstance(type);

      There are also alot of patterns as to how you make the view and view model. Again, I recomend MEF, but do your own research.. Maybe you just need a simple config file.

      Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

      1 Reply Last reply
      0
      • C columbos14927

        Hey, Ive wrote a WPF application and now i wont to give a user the this feature: 1.User will write some DLL that will be based on WPF GUI. 2.When the user will ask my application to load his DLL my APP will load it and present it on the main window then user will work with it. 3.After he will finish to work with it he will ask to unload it. Question: 1.How it possible to write DLL with WPF GUI? 2.I dont know which DLL's will be so i need to load them dynamicly,how can i do this(maybe user have to implement some inteface in his DLL)?

        D Offline
        D Offline
        Daniel Grondal
        wrote on last edited by
        #3

        To be able to unload dll's you need to load them into a separate ApplicationDomain and when you are done with the dll you need to unload the AppDomain.

        //daniel

        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