简体   繁体   English

项目参考属性-版本号

[英]Project reference properties - Version number

I have a Visual Studio project that references an assembly that I also created. 我有一个Visual Studio项目,该项目引用一个我也创建的程序集。 Below is a screen shot of the properties of my assembly reference in the project. 下面是该项目中我的装配引用的属性的屏幕截图。 When I update my assembly version to 1.1.0.0 , my project fails, and I am thinking this property is the issue. 当我将程序集版本更新为1.1.0.0 ,我的项目失败,并且我认为此属性是问题。

Since the Version attribute says 1.0.0.0 , does this mean it will always look for my assembly that has a version of 1.0.0.0 ? 由于Version属性表示1.0.0.0 ,这是否意味着它将始终寻找版本为1.0.0.0 And incrementing my version to 1.1.0.0 will cause my project to not see the assembly at all? 而将我的版本增加到1.1.0.0会导致我的项目根本看不到程序集吗?

版本:1.0.0.0

You have 2 versions of strongly named assembly. 您有2个版本的强命名程序集。 It is by design behavior for other projects that where compiled against one version of such assembly to fail to load assembly with different version. 根据设计行为,针对其他版本的程序集进行编译的其他项目无法加载具有不同版本的程序集。 The reasoning is that version change denotes API change. 原因是版本更改表示API更改。 Otherwise it would be in-place update with the same version - so older code may not be able to function correctly with newer DLL. 否则,它将使用相同版本进行就地更新-因此,较旧的代码可能无法与较新的DLL一起正常运行。

Options: 选项:

  • If there is no API changes - don't change version of assembly. 如果没有API更改-请勿更改程序集的版本。 It means you may deprecate methods, but no add/remove of methods/classes or change in behavior. 这意味着您可以弃用方法,但不能添加/删除方法/类或更改行为。
  • If you control all projects depending on that assembly - rebuild all with new reference and stop supporting older version (if possible). 如果您根据该程序集控制所有项目,请使用新的参考重新生成所有项目,并停止支持旧版本(如果可能)。
  • Provide publisher policy in settings to redirect request for older version to new one. 在设置中提供发布者政策 ,以将旧版本的请求重定向到新版本。 This assumes your new version is really backward compatible with old one. 假设您的新版本确实与旧版本向后兼容。
  • Install all versions in the GAC or just make sure applications get correct version of assembly by putting correct one next to each executable. 在GAC中安装所有版本,或者通过在每个可执行文件旁边放置正确的版本来确保应用程序获得正确的程序集版本。 It is pretty much only approach when you don't control all users of the assembly and there are significant changes in API. 当您不控制程序集的所有用户并且API有重大更改时,这几乎是唯一的方法。

Side note: depending on if the assembly in question is for internal (you control all projects using the assembly) or external consumption you may need to do more work on ensuring backward compatibility and proper deprecation policy. 旁注:根据所讨论的程序集是用于内部(使用该程序集控制所有项目)还是用于外部消耗,您可能需要做更多的工作来确保向后兼容和适当的弃用策略。

Publisher policy sample: from article linked above: 发布者政策示例:摘自上面链接的文章:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="myAssembly"
                           publicKeyToken="32ab4ba45e0a69a1"
                           culture="en-us" />
         <!-- Redirecting to version 2.0.0.0 of the assembly. -->
         <bindingRedirect oldVersion="1.0.0.0"
                          newVersion="2.0.0.0"/>
       </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

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

相关问题 Nuget软件包不包含最新代码,除非在项目属性中修改了版本号 - Nuget package does not contain latest code unless version number is modified in project properties 同一解决方案中的项目到项目参考特定版本 - Project to Project reference specific Version in same solution 修改.NET项目文件和引用属性 - Modify .NET project files and reference properties 请参阅没有特定版本号的 .net 参考 - Refer .net reference without specific version number 在.NET项目中部署时,为项目设置特定的参考版本 - Set specific reference version for project when deployed in .NET project 如何在C#中的项目的生成过程中忽略参考版本 - how to ignore reference version during build process for a project in C# 在运行时不是特定于版本的Visual Studio项目参考 - Visual Studio project reference that isn't version specific at runtime 例外:不能将对更高版本或不兼容程序集的引用添加到项目中 - Exception : A reference to a higher version or incompatible assembly cannot be added to the project 如何在project.json中引用特定版本的NetStandard? - How to reference a specific version of NetStandard in project.json? 不能将对更高版本或不兼容程序集的引用添加到项目中 - A reference to a higher version or incompatible assembly cannot be added to the project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM