如何更改程序集的公共令牌 [英] How to change the Public token of the assembly

查看:43
本文介绍了如何更改程序集的公共令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个程序集.一个组件指的是另一个组件.我检查了第一个程序集的清单,发现它使用特定的令牌密钥引用了第二个程序集.

I have two assemblies. One assembly is referring to the another one. I checked the manifest of first assembly and found it is referencing to the second one with some specific token key.

但是我检查了第二个程序集的令牌,发现它具有另一个公共令牌.所以我以某种方式错过了正确的第二次集会.因此,我想知道是否有一种方法可以将第二个程序集的公共令牌更改为第一个程序集所需的令牌.

But I checked the token of second assembly and found that it has a different public token. So somehow I missed the correct second assembly. So I want to know is there a way I can change the second assembly's public token to the one which first assembly needs.

我还有另一个第二个程序集,它的公共令牌= null.

Also I have another second assembly also which has public token = null.

推荐答案

听起来像您想重建第二个装配件并用不同的键对其进行签名,如果您有安装源的话这会很容易,所以我想您不会?

Sounds like you want to rebuild the second assembly and sign it with a different key, which would be easy if you had the source so I guess you don't?

我认为使用第二个程序集上存在的公钥令牌来重建第一个程序集,使其引用您拥有的第二个程序集会更容易.更简单,但也不完全简单.

I think it would be easier to rebuild the first assembly so that it references the second assembly you have, using the public key token that is present on the second assembly. Easier, but not entirely straightforward.

我认为您应该能够通过以下方式实现此目的:通过 ildasm.exe 运行第一个程序集,更改对第二个程序集的引用上的公钥令牌,然后通过 ilasm.exe ,以生成第一个程序集的新版本.

I think you should be able to achieve it by running the first assembly through ildasm.exe, change the public key token on the reference to the second assembly, and then run the result through ilasm.exe, to produce a new version of the first assembly.

所涉及步骤的粗略概述...

A rough outline of the steps involved...

  1. 运行 ildasm.exe/out=first.il first.dll (或 first.exe )
  2. 编辑 first.il 并找到 .assembly extern块,以引用 second.dll
  3. 更改该区块中的公钥令牌
  4. 首先运行 ilasm.exe 以生成 first.dll (或 first.exe )
  1. Run ildasm.exe /out=first.il first.dll (or first.exe)
  2. Edit first.il and find the .assembly extern block for the reference to second.dll
  3. Change the public key token in that block
  4. Run ilasm.exe first.il to produce first.dll (or first.exe)

请注意,我已经很长时间没有使用过这些工具了,从不以这种方式来操作公钥令牌,因此您可能必须添加一些自己的独创性.但另一方面,我想不出这种方法不起作用的原因.

Be warned, I haven't used these tools for a long time, and never to manipulate public key tokens in this way, so you will probably have to add some ingenuity of your own. But on the other hand, I can't think of a reason for this approach not to work.

这篇关于如何更改程序集的公共令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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