1

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. Is there code for doing it?

Note: I am using C#.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Fioenix
  • 39
  • 1
  • 6

2 Answers2

13

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.

Jon Skeet
  • 1,261,211
  • 792
  • 8,724
  • 8,929
0

If you're talking about building an extensible application in C# that loads other assemblies and uses their contents for extending the application, then see Stack Overflow question System with plugins in C#.

Community
  • 1
  • 1
plinth
  • 45,549
  • 9
  • 75
  • 118