Get a list of functions for a DLL

后端 未结 2 1843
情话喂你
情话喂你 2021-01-15 23:29

I\'m building a project. It\'s an application that users can add their extensions (DLL files) to. To manage an extension, I need to get its list of classes, functions, etc.

2条回答
  •  [愿得一人]
    2021-01-15 23:46

    For a particular assembly, you can use Assembly.GetTypes to get the types, then for each type call Type.GetMethods(), Type.GetProperties() etc, or just Type.GetMembers().

    However, for plugin functionality it's usually a good idea to have a common interface which the plugins have to implement - that reduces the amount of reflection you need to use. Use Type.IsAssignableFrom() to check whether a type is compatible with a particular interface.

    You might also want to look at the Managed Extensibility Framework which can make implementing an extension system easier.

提交回复
热议问题