开发者

Reflection and strong named assemblies

开发者 https://www.devze.com 2023-01-28 11:44 出处:网络
I have created a test project whose output will be strong named assembly. I have specified the SNK file name in the \'project -> properties - > Signing\' section so that assembly will be strong named
  1. I have created a test project whose output will be strong named assembly. I have specified the SNK file name in the 'project -> properties - > Signing' section so that assembly will be strong named. I added reference of the assembly which is NOT signed or strong named. I was expecting that my project will not at all build since it's referencing unsigned assembly. However, it built and i could install the assembly in GAC too! Why is it so? (I'm using .NEt 4.0 and it's gacutil.exe) Note: I have ensured that the assembly which is being referenced is NOT strong named.

  2. Can i programatically load the 'unsigned' (i.e. non-strong named) assembly in my program whose开发者_开发问答 output is going to be strong named assembly? If yes, why is it allowed to do so when on the other hand, .NET don't allow to add reference to unsigned assemblies?

  3. If I have multiple versions of the same assembly in GAC. In my configuration file, If I specify just the name of the assembly, which version will be loaded from GAC? Will it be latest version everytime? Which API will be useful? I found many methods marked 'deprecated' in Assembly class.


You can reference the unsigned assembly in VS.Net from a signed assembly. But if you call anything from the signed to the unsigned, the build will fail.


  1. There is no problem in signed assembly referencing an unsigned assembly. It can be done and signed assembly can be GACed.

  2. Yes, you can load.

  3. How can you specify assembly by just name ? There is only one API LoadWithPartialName and thats deprecated for many reasons. You need version, culture and public key token to uniquely identify assembly.

0

精彩评论

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

关注公众号