升级 C# 项目中的参考 dll,无需重新编译项目
我需要获取 C# 应用程序的构建版本并更改其中一个参考 dll。最好的方法是什么,我在参考 dll 上关闭了特定版本,但是当我测试用较新版本替换 dll 时,我得到“无法加载文件或程序集 XXXXX,版本 = XXXXX。是有没有办法阻止加载程序关心 dll 的版本,以便 dll 只会尝试加载?
I need to take a built version of an C# application and change one of the reference dll's. What is the best way to do this, I have specific version turned off on the reference dll but as soon as I test replacing the dll with a newer version, I get the "Could not load file or assembly XXXXX, Version=XXXXX. Is there a way to stop the loader from caring about the version of the dll so the dll will just attempt to load?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以执行此操作 - 请参阅 MSDN 文章 重定向程序集版本。
您应该阅读整个文档,但它本质上涉及程序集的发布者创建“发布者策略文件”或消费者将
bindingRedirect
添加到app.config
文件,例如this(直接从文章中复制):一些注释:
如果您没有明确指定
你的文化(很多人没有),它会
是“中立”而不是“en-us”。
如果你还不知道,你可以
获取程序集的公钥令牌
使用强名称实用程序,例如
this:
sn -t [AssemblyPath]
Yes, you can do this - see the MSDN article Redirecting Assembly Versions.
You should read the whole document, but it essentially involves either the assembly's publisher creating a 'publisher policy file' or the consumer adding a
bindingRedirect
to anapp.config
file, like this (copied directly from the article):A few notes:
If you haven't explicitly specified
your culture (as many don't), it will
be "neutral" rather than "en-us".
If you don't already know it, you can
get the assembly's public key token
using the strong name utility, like
this:
sn -t [AssemblyPath]