Setting up C# solution with multiple projects using NLog in Visual Studio

Robert Strauch picture Robert Strauch · Mar 12, 2013 · Viewed 7.7k times · Source

My solution in Visual Studio 2012 currently contains two projects:

  • DLL
  • WPF application (which requires methods of the DLL)

Both, the DLL and the WPF application, use NLog for logging. Currently each project contains the NLog DLL itself.

Here is what I don't understand:

  1. It seems unnecessary to me including the identical NLog DLL in each project.
  2. The DLL however shall be reusable in other solutions, i.e. somehow the NLog DLL must be contained in the DLL project.

What would be an adequate way of setting up the Visual Studio solution and/or projects?

Answer

Davide Piras picture Davide Piras · Mar 12, 2013

well you need the DLL in all projects where you use it and surely you need it deployed with the binaries of the executable (WPF application in your case) so that it can be found and used at runtime.

what I tend to do in all my projects is create a wrapper around the logging engine so that I do not need to reference and depend on specific third party logging APIs, like Log4Net or NLog, so I use my wrapper logging class everywhere and then I have a reference to the logging asembly only in the wrapper class's project and in the executable project to have the assembly deployed to the bin folder.

hope this helps ;-)