简体   繁体   中英

How to develop applications in C# that can be further extended using DLL add-ins? Like .NET Reflector

How can I develop applications in C# that can be further extended using DLL add-ins?

Like .NET Reflector can browse and load DLLs at runtime.

I searched for tutorials but I couldn't find anything. Maybe I wasn't searching using the right keywords.

看看托管扩展框架: http : //mef.codeplex.com/

Basically in very brief and high-level terms, what you need to do is define one or more interfaces that your application will use to interact with the extension. Then individuals that want to write an extension for your application will implement your predefined interfaces and then register the implementation with your application. Registration could be as simple as dropping the extension DLL in a directory and your application will enumerate the directory load the extension dlls and start interacting with the classes that implement you expectd interfaces.

Take a look at for following methods for a starting point on dynamically loading assemblies and creating instances of classes at runtime

System.Activator.CreateInstance
System.Reflection.Assembly.LoadFrom

Of course there is much more to it, but this should give you a starting point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM