We have a rather large base of C # code for a product that has been divided into many assemblies in order to avoid a monolithic product and to ensure compliance with some code quality standards (client-specific functions are included in client-specific nodes to preserve the "core", the general and unburdened by dependence on customer-specific business logic). We call these plugins internally, but they are more modules that make up the overall product.
How it works, the DLL files of these modules are copied to the directory, the runtime of the application (either the ServiceStack IIS web application, or the quartz-based console application), and then Assembly.LoadFilefor each module that is not in the list of already loaded assemblies ( AppDomain.CurrentDomain.GetAssemblies()).
This one PluginLoaderloads only the assemblies present in the file plugins.config, but I think that this is mostly irrelevant to the problem.
Full code for the class PluginLoader:
https://gist.github.com/JulianRooze/9f6d1b5e61c855579203
It works. Like. It is fragile, although it suffers from a problem when assemblies are downloaded twice in this case from different places (usually from the / bin / folder of the application and the plugin directory). This is similar to the fact that at the time the class is called PluginLoader AppDomain.CurrentDomain.GetAssemblies()(at startup) it does not necessarily return the final list of assemblies that the program will load by itself. Therefore, if there is an assembly in the / bin / called dapper.dll file (a common dependency of both the kernel and many plugins / modules) that have not yet been used by the program, then it has not yet been loaded (in other words: it lazily loads them). Then, if dapper.dll is also a plugin, it PluginLoaderwill see that it is not loaded yet and will load it. Then, when the program uses its Dapper dependency, it will load dapper.dll from / bin /, and now we will have two dapper.dll files loaded.
. RazorEngine, .
:
?
, Jon Skeet. ( , - ), . -, DLL , /bin/, , .NET. - . , /bin/ DLL, , . , ( dev, , ).
, Jon Skeet, Gist PluginLoader LoadReferencedAssemblies. :
- ,
System.Runtime.Serialization , . - , . .
Managed Extensibility Framework, , . , , , , .
, " DLL - ", ?:)
, , .