大会名称和版本 [英] Assembly names and versions

查看:160
本文介绍了大会名称和版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么被认为是最好的做法,当谈到组件和发布

What is considered as best practice when it comes to assemblies and releases?

我希望能够引用同一个库的多个版本 - ?解决方案包含多个依赖于不同的版本中,我们要建造一座commonutils.dll库的项目。

I would like to be able to reference multiple versions of the same library - solution contains multiple projects that depend on different versions of a commonutils.dll library we build ourselves.

由于所有的依赖被复制到bin / Debug或Bin /释放,只有一个副本的commonutils.dll尽管可以有各自不同的装配版本号的DLL文件存在。

As all dependencies are copied to the bin/debug or bin/release, only a single copy of commonutils.dll can exist there despite each of the DLL files having different assembly version numbers.

我应该在程序集名称版本号为能够引用多个版本?库或有另一种方式

Should I include version numbers in the assembly name to be able to reference multiple versions of a library or is there another way?

推荐答案

这就是我一直生活由 -

Here's what I've been living by --

这取决于你打算使用的DLL文件什么。我将其归类于两大类:

It depends on what you are planning to use the DLL files for. I categorize them in two main groups:


  1. 死端组件。这些都是EXE文件和DLL文件你真的没有从任何地方引用规划。只是弱命名这些,并确保你有你释放标记的源代码控制的版本号,这样你就可以随时回滚

  1. Dead-end Assemblies. These are EXE files and DLL files you really aren't planning on referencing from anywhere. Just weakly name these and make sure you have the version numbers you release tagged in source-control, so you can rollback whenever.

引用的程序。强名称,这些让你可以拥有它的多个版本的其他组件所引用。使用完整名称引用它们(的Assembly.Load)。保持它的最新款和最伟大的版本的副本在一个地方,其他代码可以引用它。

Referenced Assemblies. Strong name these so you can have multiple versions of it being referenced by other assemblies. Use the full name to reference them (Assembly.Load). Keep a copy of the latest-and-greatest version of it in a place where other code can reference it.

接下来,你是否要复制本地或不是你的参考选择。基本上,权衡归结为 - 你想在您引用的补丁/升级?可以有正的值在从获得新的功能,但是,另一方面,可能有重大更改。这里的决定,我认为,应在逐案基础上作出。

Next, you have a choice of whether to copy local or not your references. Basically, the tradeoff boils down to -- do you want to take in patches/upgrades from your references? There can be positive value in that from getting new functionality, but on the other hand, there could be breaking changes. The decision here, I believe, should be made on a case-by-case basis.

虽然在Visual Studio中开发,在默认情况下你将采取的最新版本编译的使用,但一旦编译引用大会将要求它与编译的具体版本。

While developing in Visual Studio, by default you will take the latest version to compile with, but once compiled the referencing assembly will require the specific version it was compiled with.

您最后的决定是复制本地与否。基本上,如果你已经在地方部署引用的程序集的机制,这种设置为false。

Your last decision is to Copy Local or not. Basically, if you already have a mechanism in place to deploy the referenced assembly, set this to false.

如果你正在规划一个大放管理系统,你可能要放很多更多的思考和关心这个。对我来说,(小商店 - 两个人),这工作正常。我们知道发生了什么事情,也不要觉得从的具有的做事情的方式,没有意义。

If you are planning a big release management system, you'll probably have to put a lot more thought and care into this. For me (small shop -- two people), this works fine. We know what's going on, and don't feel restrained from having to do things in a way that doesn't make sense.

在克制你达到运行时,你的Assembly.Load任何你想要进入应用领域。然后,您可以使用Assembly.GetType达到你想要的类型。如果你有一个类型存在于多个加载的程序集(如在同一个项目的多个版本),你可能会得到一个的 AmbiguousMatchException 例外。为了解决这一点,你将需要获得类型进行装配变量,而不是静态Assembly.GetType方法的一个实例。

Once you reach runtime, you Assembly.Load whatever you want into the application domain. Then, you can use Assembly.GetType to reach the type you want. If you have a type that is present in multiple loaded assemblies (such as in multiple versions of the same project), you may get an AmbiguousMatchException exception. In order to resolve that, you will need to get the type out of an instance of an assembly variable, not the static Assembly.GetType method.

这篇关于大会名称和版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆