Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Is there a way to load assemblies <em>dynamically</em> to use <em>without</em> having to restart the service?</p> </blockquote> <p>Yes, there is. I suppose you have one or more types that have to be instantiated. If this is your case consider using something like this:</p> <pre><code>object instance = Activator.CreateInstance("MyAssembly.dll", "MyType"); instance.GetType().InvokeMethod(etc); </code></pre> <p>If you are running under .NET Framework 4.0 you could make use of DLR:</p> <pre><code>dynamic instance = Activator.CreateInstance("MyAssembly.dll", "MyType"); instance.MyMethod(); </code></pre> <p><strong>EDIT:</strong> Alternatively you could take a look at <a href="http://mef.codeplex.com/" rel="nofollow">MEF</a> (it is part of .NET Framework 4.0). </p> <blockquote> <p>MEF presents a simple solution for the runtime extensibility problem.</p> </blockquote> <p>Basically (<strong>I'm simplifying a lot</strong>) you can specify which folder has to be chosen for taking up the assemblies and then MEF will automatically instantiate the objects that, for example, share the same interface.</p> <p>Shared Interface:</p> <pre><code>public interface IPlugin { void ExecuteTask(); } </code></pre> <p>Plugin (external assembly):</p> <pre><code>[Export(typeof(IPlugin)] public class Plugin1 : IPlugin { public void ExecuteTask() { // Do something } } </code></pre> <p>Main Application:</p> <pre><code>[Import] private IPlugin plugin; // Somewhere else private void Initialize() { var directory = new DirectoryCatalog("myDir"); var container = new CompositionContainer(directory); container.ComposeParts(this); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload