Many modern modular application products consist of the main application and several plug-ins. it has become popular to utilize the Unity Framework and Prism for WPF, which allows decoupling of the parts of the application from one another. The plug-ins are loaded at runtime using reflection. Usually the main application has the list of plug-in modules to load defined in its configuration file. Naturally the main application does not need to know of the existence of a particular plug-in or its internal structure until the execution time.
In such Visual Studio solution it makes sense not to add the plug-in projects or assemblies as references to the main application. However this presents the challenge when one needs to deploy the application with the plug-ins via ClickOnce. The ClickOnce architecture doesn’t allow one to include arbitrary files that are not part of the project.
It turns out there is no real harm in adding a project reference or a DLL reference to the main project. It’s true that during the compile time, the referenced assembly is passed to the compiler as the /r:MyReferencedAssembly.dll. However the compiler is smart enough to recognize that the main project makes no use of any of the classes inside the child assembly, and the reference is simply ignored.
For example, in the following screenshots, I used Red Gate’s .NET reflector to show that even though I added a reference to the project called MyPlugIn, the compiled assembly does not have any reference to it.
I hope this article saves time for another perfectionist developer like me :)
dc6a3cb3-b866-4461-8374-49efd01a6e97|0|.0