如何让 ac# 项目忽略程序集的版本号?
我正在开发一个引用另一个产品的 dll 的项目。该产品每年都会发布一个版本,并且每个版本的程序集版本都会发生变化,但方法保持不变。 当我运行 2010 年项目的构建时,当我尝试运行 2009 年项目时,它会抛出错误,因为它依赖于不同的版本。有办法解决这个问题吗?
I am working on a project that references dlls from another product. The product has a release each year and the assemblies version changes for each one, although the methods stay the same.
When I run a build of my project for 2010 when I try and run it for 2009 it throws an error because it is dependent on a different version. Is there a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在交换程序集版本后提到运行时出现问题,而没有执行引用新构建程序集的程序重建,则您需要使用
指令到您的程序App.config(或 Web.config,如果您谈论的是网站。)bindingRedirect
用于指示 .NET Framework 可以使用程序集的版本其他 比应用程序最初编译时所针对的版本要高。默认情况下,CLR 希望看到应用程序在构建期间引用的 DLL 的同一版本,如果不是,则会抛出异常。If you're referring to a problem at runtime after swapping versions of your assembly without performing a rebuild of the program referencing your newly built assembly, you'll want to use a
<bindingRedirect>
directive to your program's App.config (or Web.config, if you're talking about a web site.)bindingRedirect
is used to instruct the .NET Framework that it's OK to use a version of an assembly other than the one the application was originally compiled against. By default, the CLR wants to see the same version of a DLL that your application was referencing during build, and if it doesn't it will throw an exception.尝试选择引用,并在属性窗口中将特定版本设置为 false。
Try selecting the reference, and in property window set Specific Version as false.
可以在放入应用程序根文件夹的 app.config 中映射不同的 .net 版本的程序集。
当您引用的程序集内部引用另一个特定库版本时,这是解决方案。
当编译时“特定版本”设置为 true 时会发生这种情况。为了避免这个问题,它应该是错误的。
It is possible to map different .net version of assembly in app.config that you put in application root folder
This is solution when assembly you have referenced has references inside it to another specifc library version.
It happens when at compilation time "Specific version" is set to true. To avoid this problem it should be false.