开发者

Use dll with different PublicToken property without recompilation

开发者 https://www.devze.com 2023-03-11 14:49 出处:网络
I have .net dll, it use different .开发者_高级运维net dll with PublicToken set to null. Now I have to use the same version of different dll but with PublicToken set to some other value. Is there a way

I have .net dll, it use different .开发者_高级运维net dll with PublicToken set to null. Now I have to use the same version of different dll but with PublicToken set to some other value. Is there a way to use it without a need of recompilation of first dll (I do not have sources).


I don't think there is a clean way of doing this, mainly because what you are trying to do is defeat the very purpose of the Strong Naming concept. bindingRedirect only works on version, not the key. The only way that I can think of is to disable Strong Name Verification:

sn.exe -Vr TheAssembly

You can learn more about that here.

The problem with it is, it has to be done on every machine this is run.

Another alternative is to use a tool like Mono.Cecil to strip the Public Key Token from the Module's Assembly References so it no longer cares. If it is strong named itself, you'd have to remove that too. This option generally works, but will in most cases violate any form of EULA the assembly comes with if it is a commercial product.

0

精彩评论

暂无评论...
验证码 换一张
取 消