locked
call a method in a dynamically loaded assembly RRS feed

  • Question

  • Hi,

    We have dynamically loaded an assembly into application memory using 'Assembly.Load()' method. Now we need to execute a method within a class in the dynamically loaded assembly after passing its parameters. How can we acheive this?

    regards
    Sreejith

    Tuesday, June 9, 2009 6:12 AM

Answers

  • Call Assembly.GetType to get the Type you want to work with, Activator.CreateInstance to instantiate it (unless you want to just call static methods) and the Type.InvokeMember to call its methods.
    Mattias, C# MVP
    • Marked as answer by SSreejith Tuesday, June 9, 2009 1:49 PM
    Tuesday, June 9, 2009 7:19 AM

All replies

  • Call Assembly.GetType to get the Type you want to work with, Activator.CreateInstance to instantiate it (unless you want to just call static methods) and the Type.InvokeMember to call its methods.
    Mattias, C# MVP
    • Marked as answer by SSreejith Tuesday, June 9, 2009 1:49 PM
    Tuesday, June 9, 2009 7:19 AM
  • Call Assembly.GetType to get the Type you want to work with, Activator.CreateInstance to instantiate it (unless you want to just call static methods) and the Type.InvokeMember to call its methods.
    Mattias, C# MVP
    GetType method does not work when Assembly is loaded from byte[] not from filesystem. My assemlies are in database and   I am currently looking for solution. If I find it I will post it here.
    Saturday, July 4, 2009 12:51 PM