简体   繁体   English

VS解决方案,项目与dll最佳实践

[英]VS Solution, projects vs dlls best practice

Whenever I have a library that use across different websites/ applications I've always just added the library's project into the same solution and reference it from there. 每当我有一个在不同网站/应用程序中使用的库时,我总是将库的项目添加到同一个解决方案中并从那里引用它。 This is great when needing to debug within the solution but in all other situations it seems pointless and more space taken up in the solution explorer. 当需要在解决方案中进行调试时,这很好,但在所有其他情况下,它似乎毫无意义,并且在解决方案资源管理器中占用了更多空间。

Also another positive or negative is that if that library is updated by someone else in the company and I then build another application which uses the same thing they could possibly have broken the build. 另一个正面或负面的是,如果该库由公司中的其他人更新,然后我构建另一个使用相同的东西的应用程序,他们可能已经破坏了构建。 If for whatever reason that cannot be fixed with the current application then you could go back into your source control and roll back to an older version, but this seems a bit too OTT. 如果出于某种原因无法使用当前应用程序修复,那么您可以返回到源代码控制并回滚到旧版本,但这似乎有点过于OTT。

I was just wondering what other people's thoughts on this subject are. 我只是想知道其他人对这个问题的想法是什么。 What do you normally do, reference the dll or do you add the project to your solution. 你通常做什么,参考dll或你是否将项目添加到您的解决方案。

We keep our production Dlls in a well-known location on a network drive and reference is via the DFS UNC path (no drive letter). 我们将生产Dll保存在网络驱动器上的一个着名位置,并通过DFS UNC路径引用(无驱动器号)。 This way we can have different versions of the library in use at the same time and updates don't break code/force a recompilation until the newer version needs to be used. 这样我们可以同时使用不同版本的库,并且在需要使用较新版本之前,更新不会破坏代码/强制重新编译。 A standard naming scheme can be used to ensure that if a project always wants to use the latest version it can. 标准命名方案可用于确保项目始终要使用最新版本。

You could also register your dll in the GAC. 您也可以在GAC中注册您的dll。 The GAC handles all referencing, versioning etc and is secure. GAC处理所有引用,版本控制等,并且是安全的。 Having assigned a strong key which is a pre requisite for dlls sitting in the GAC you have a secure way of accessing Dll's and where you are using a shared server this can be invaluable. 分配了一个强密钥,这是访问GAC的dll的先决条件,您可以安全地访问Dll,并且您使用共享服务器,这可能是非常宝贵的。 Your sites which use this dll have a central port of call for the assembly. 您使用此dll的站点具有组件的中央调用端口。 The GAC has a whole host of advantages with several articles on MSDN and no doubt hundreds on google dedicated to it. GAC在MSDN上有几篇文章有很多优势,毫无疑问,谷歌有数百篇文章致力于它。

Keep the library in some shared folder between projects, and just reference it. 将库保存在项目之间的某个共享文件夹中,并引用它。 That way when its updated, the changes will be persisted everywhere. 这样,当它更新时,变化将持续到处。 For debugging, i think if you keep the .pdb files for the library handy then you should be able to step into the dlls, however, should you be concerned with debugging a library? 对于调试,我认为如果您方便地保存库的.pdb文件,那么您应该能够进入dll,但是,如果您关心调试库?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM