Search code examples
c#dynamic-assemblies

Load assembly every time or only once


I'm building an extensible service application for my work, and the way it 'extends' is by loading DLL's and executing methods within. It is designed this way so that I do not need to recompile and re-deploy every time we have a new job for it to do. Currently, the service loads a DLL using Assembly.LoadFrom() and then it registers the assembly with the service. In the registration, a Func<object, bool> is passed that dictates the entry point for the new job.

My question is would it be better if I created the instance every time I needed to run the task via something similar to this:

IRunable run = (IRunable)asm.CreateInstance(t.FullName, true);
run.Run();

or would it be better to do it the way I am currently, where I store the Func<> in a class that is called based of a timer?


Solution

  • Timer!

    If the performance might stuck because of it (i always had this problem in c#) u can still change it, but a timer gives you more controll over the programm itself...

    But implementing a buffer should also just work fine