---
title: "About Dynamic Plug-in Discovery And AppDomains"
url: "https://osherove.com/blog/2003/5/28/about-dynamic-plug-in-discovery-and-appdomains.md"
canonical: "https://osherove.com/blog/2003/5/28/about-dynamic-plug-in-discovery-and-appdomains.html"
published: "2003-05-28T04:18:00"
updated: "2003-05-28T04:18:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "I've gotten several comments on my Plug-ins article which was published both here and on CodeProject . One of them mentions the obvious missing feature for a plugin architecture - Dynamically discovering plugins without…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# About Dynamic Plug-in Discovery And AppDomains

By Roy Osherove May 28, 2003 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published May 28, 2003; technical details may be outdated.

I've gotten several comments on my [Plug-ins article](http://dotnetweblogs.com/rosherove/story/7610.aspx) which was published both [here](http://dotnetweblogs.com/rosherove/story/7610.aspx) and on [CodeProject](http://www.codeproject.com/csharp/Plugins.asp). One of them mentions the obvious missing feature for a plugin architecture - Dynamically discovering plugins without the need for configuration files.

In essence, what you would do is go through the folder in which application is located, and search for assemblies with types that implement the "IPlugin" interface. One problem here - In order to check an assembly, you must load it; assemblies can't be unloaded without unloading the whole AppDomain in which they reside .If you unload your own appDomain - you're basically shutting down you application. problem.

A way to resolve this would be to load a separate AppDomain and load the searched assemblies into that one. Then make a separate list of the assemblies that match your criteria and only load those into a seperate AppDomain. This gives you 2 advantages:

1.   You can dynamically search for added or changed plugins at runtime
2.   You don't save 'garbage' assemblies at run-time.

I'll try to implement this solution in the coming days. Meanwhile, here's a good MSDN article about loading and unloading AppDomains.

# [AppDomains and Dynamic Loading](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp?fram)

I'm also thinking of purchasing this book:

[C# Threading Handbook](https://www.amazon.com/exec/obidos/ASIN/1861008295/qid%3D1054106350/sr%3D11-1/ref%3Dsr%5F11%5F1/iserializable-20)

Anyone know about it? Other recommendations?

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- May 28, 2003

    ### [Create More Readable Code By Interface Prefixes](https://osherove.com/blog/2003/5/28/create-more-readable-code-by-interface-prefixes.html)

- May 28, 2003

    ### [.Net Developer Journal May Issue PDF download](https://osherove.com/blog/2003/5/28/net-developer-journal-may-issue-pdf-download.html)

- May 27, 2003

    ### [New Article: Extend Your Application With Custom Plugins](https://osherove.com/blog/2003/5/27/new-article-extend-your-application-with-custom-plugins.html)

- May 26, 2003

    ### [.Net Debugging Resources](https://osherove.com/blog/2003/5/26/net-debugging-resources-1.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
