2

What ways have people found/used to add functionality to a .NET/C# app without recompiling?

The methodology that comes to mind for me is having code that looks for a file to read, parses that file, and then dynamically creates controls and their event handlers, etc., based on what is contained in the file (possibly an xml file).

Or would dynamically loading .DLLs be considered "not recompiling"?

Any ideas/"war stories"?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • Maybe, loading a javascript file and executing it as a container like browsers do. http://stackoverflow.com/questions/9668006/running-javascript-in-c-sharp-application-with-arguments-and-return/9669148#9669148 – L.B Mar 13 '12 at 17:18
  • See this question: http://stackoverflow.com/questions/835182/choosing-between-mef-and-maf-system-addin – Eric Lippert Mar 13 '12 at 18:07

3 Answers3

6

All you need - MEF - Managed Extensibility Framework

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Stilgar
  • 22,354
  • 14
  • 64
  • 101
2

For fairly simple cases with well defined behaviors:

Define an interface for you plugin. Implement the interface in dlls. Load dlls with Assembly.LoadFrom.

I'd add a GUID to each dll too so you can tell them apart.

Matt Burland
  • 44,552
  • 18
  • 99
  • 171
1

Look at how ASP.Net does it - you can add ASPX/ASPX.cs file while site is running. Short version: ASP.Net listens for file changes and compiles new files into new assemblies, than loads into existing AppDomain to use for rendering new pages.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179