在项目中添加库引用的建议是什么?

发布于 2024-12-09 08:25:22 字数 284 浏览 0 评论 0原文

当我需要添加对库的引用时,我总是被告知使用“添加现有项目”方法,并在我的解决方案中引用项目本身。

但在我的新公司,使用另一种方法。他们有一个服务器来保存已编译的 dll,并保留它们的版本,以便当更改太重要而无法重构旧应用程序时,他们可以引用旧版本。

虽然我发现这个系统确实很复杂(我猜如果更新了指向旧版本 dll 的程序并且需要对此 dll 进行一些更改,则需要做很多工作),但他们似乎发现它非常方便。

这方面的最佳实践是什么?直接链接dll?链接项目?为什么?欢迎任何信息!

提前致谢 !

When I need to add a reference towards a library, I've always been told to use the "add existing project" method, and referencing the project itself inside my solution.

But here in my new company, the use another method. They have a server which holds the compiled dll's, and keep versions of them so they can reference older versions when a change is too important to refactor older apps.

While I find this system really complicated (I guess there is a lot of work if a program pointing an older version of the dll is updated and needs some changes in this dll), they seem to find it pretty convenient.

What are the best practices for this? Linking the dll directly? Linking the project? And why? Any information is welcome!

Thanks in advance !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

情泪▽动烟 2024-12-16 08:25:22

我通常会获取编译后的 dll 的副本(如果源项目不可用或者我不需要源)并将其放入解决方案内的文件夹中,然后引用它。我将其与我的项目一起签入源代码管理。

我认为你应该能够检查一个项目并直接从源代码管理构建它,而不必去寻找 dll 等。

I usually take a copy of the compiled dll (if the source project is not available or if I don't need the source) and put it in a folder inside my solution, and then reference that. I check it in to source control along with my project.

I am of the opinion that you should be able to check out a project and build it directly from source control without having to go hunting dlls etc.

饮惑 2024-12-16 08:25:22

当您想要引用并行开发的库项目并且想要测试/使用它时,添加现有项目方法非常有用typesmethods 以及这个(添加现有项目)方法不会用于添加预编译的引用> (dll) 文件。

阅读项目参考 (MSDN) 文章。

The Add existing project method is useful when you want to reference a library project which is develop side by side and you want to test/use it's types and methods and this (Add existing project) method will not be used to add the reference of pre-compiled (dll) files.

Read Project Reference (MSDN) article.

过去的过去 2024-12-16 08:25:22

当您想要同时处理该库时,您可以将其作为项目包含在内。这种情况主要发生在将与程序(bin 文件夹)一起分发的小型库中。

当程序集(将要)安装在 GAC 中并因此具有自己的发布周期时,仅引用二进制文件更有意义。

上述的几种组合也是可能的。

You would include it as a Project when you want to simultaneously work on the library. And that would happen mostly for small(ish) libs that will be distributed with your program (bin folder).

When an assembly is (going to be) installed in the GAC, and thus has its own release cycle, it makes more sense to reference the binary only.

Several combination of the above are possible too.

奈何桥上唱咆哮 2024-12-16 08:25:22

添加编译的 dll 主要是当代码或多或少被锁定(架构级别代码)时,您几乎不会更改
例如

1) 通信层(远程/wcf)

2) 通用 Gui 层(向导/对话框)

3) 安全层(azman 的东西)

你只需要在你的产品走向另一个方向时改变,比如它使用 .net 远程处理现在作为通信,它将使用 WCF

当您经常更改引用的项目时,使用项目作为参考
Visual Studio 也很好地制定了构建项目的顺序。

Adding Compiled dlls is mainly when the code is more or less locked (Architecture level code ) which you hardly ever changes
eg

1) communication layer(remoting/wcf)

2) Generic Gui layer (Wizards/dialog boxes)

3) Security layer (azman stuff)

you only need to change when your product is going to another direction say it uses to use .net remoting as communication now it will be using WCF

Using projects as reference when you are frequently changes referenced projects
also Visual studio works out nicely order of building the projects.

墨落成白 2024-12-16 08:25:22

尽管贵公司的方法在 Microsoft 开发人员中可能不是很常见,但它在 Java 世界中使用得相当成功。从长远来看,它可能比任何替代方案都更好控制,但如果没有相当数量的支持脚本/程序(例如,在需要时自动更新项目/解决方案),它很容易变得难以管理。在 Java 世界中,它直接由 Maven 等工具支持。

Although your company's approach is probably not very common among Microsoft developers, it is used rather successfully in the Java world. In the long run it is probably better controlled than any alternative, but without a fair amount of support scripts/programs (which, for instance, update projects/solutions automatically when needed) it can easily become unmanageable. In the Java world it is directly supported by tools such as Maven.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文