问题描述
我在Visual Studio 2012中的解决方案当前包含两个项目:
My solution in Visual Studio 2012 currently contains two projects:
- DLL
- WPF应用程序(需要DLL的方法)
DLL和WPF应用程序都使用NLog
进行日志记录.当前,每个项目本身都包含NLog
DLL.
Both, the DLL and the WPF application, use NLog
for logging. Currently each project contains the NLog
DLL itself.
这是我不明白的地方:
- 在我看来,在每个项目中都包含相同的
NLog
DLL. - 但是该DLL应该可以在其他解决方案中重用,即
NLog
DLL必须包含在DLL项目中.
- It seems unnecessary to me including the identical
NLog
DLL in each project. - The DLL however shall be reusable in other solutions, i.e. somehow the
NLog
DLL must be contained in the DLL project.
设置Visual Studio解决方案和/或项目的适当方法是什么?
What would be an adequate way of setting up the Visual Studio solution and/or projects?
推荐答案
在所有使用DLL的项目中都需要DLL,并且确实需要将其与可执行文件的二进制文件一起部署(在您的情况下为WPF应用程序),以便可以在运行时找到并使用它.
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.
我在所有项目中倾向于做的事情是围绕日志记录引擎创建一个包装器,这样我就无需引用并依赖特定的第三方日志记录API(例如Log4Net或NLog),因此我在所有地方都使用了包装器日志记录类然后我仅在包装类的项目和可执行项目中引用了日志记录程序集,以将程序集部署到bin文件夹中.
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 ;-)
这篇关于在Visual Studio中使用NLog设置具有多个项目的C#解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!