Load a .DLL file and access methods from class within?

前端 未结 3 1000
深忆病人
深忆病人 2020-11-30 04:36

I\'m completely new to loading in libraries like this, but here\'s where I stand:

I have a homemade DLL file it\'s about as simple as it gets, the class itself and a

3条回答
  •  天命终不由人
    2020-11-30 05:23

    Use Assembly.GetTypes() to get a collection of all the types, or Assembly.GetType(name) to get a particular type.

    You can then create an instance of the type with a parameterless constructor using Activator.CreateInstance(type) or get the constructors using Type.GetConstructors and invoke them to create instances.

    Likewise you can get methods with Type.GetMethods() etc.

    Basically, once you've got a type there are loads of things you can do - look at the member list for more information. If you get stuck trying to perform a particular task (generics can be tricky) just ask a specific question an I'm sure we'll be able to help.

提交回复
热议问题