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 an assembly dynamically and using types/functions in it

Loading an assembly dynamically and using types/functions in it

Scheduled Pinned Locked Moved C#
hardwaretutorialquestionlearning
2 Posts 2 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.
  • B Offline
    B Offline
    Bojan Rajkovic
    wrote on last edited by
    #1

    I'm trying to load an assembly dynamically (IE. extracting it as an embedded resource, and then using Assembly.Load() to load it) and then use the types and functions that are built into it, but I can't figure out how to get access to them, nor could I find any good tutorials. Any hints, or am I trying the impossible?

    S 1 Reply Last reply
    0
    • B Bojan Rajkovic

      I'm trying to load an assembly dynamically (IE. extracting it as an embedded resource, and then using Assembly.Load() to load it) and then use the types and functions that are built into it, but I can't figure out how to get access to them, nor could I find any good tutorials. Any hints, or am I trying the impossible?

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      You can use Assembly.Load or Assembly.LoadFrom(). Those function will return you an Assembly object. You can then call GetTypes() on that object to get the list of all types. For each Type object, you can then call Activator.CreateInstance() to create an instance and then Type's InvokeMember() to call methods. Something like Assembly assembly = Assembly.Load("..."); foreach(Type t in assembly.GetTypes()) { Object obj = Activator.CreateInstance(t); t.InvokeMember("MyMethod", BindingFlags.Instance, null, obj, null); } Hope this helps. Regards Senthil My Blog

      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