Home   Cover Cover Cover Cover
 

Delay signing

Question: see book

Answer: see 8.5.2 Strong Name Tool (sn.exe)

The following command line extracts the public key from a public/private key pair file:

sn /p mykeys.snk mypubkey.snk

After modifying the attribute AssemblyKeyFile and adding the attribute AssemblyDelaySign to the source code

MyLib1.cs
using System.Reflection;

[assembly: AssemblyKeyFile("mypubkey.snk")]
[assembly:AssemblyDelaySign(true)]

public class MyLib {
  public static int getTen () { return 10; }
}

the compiler will put the public key into the resulting assembly and leave enough space for later introduction of the signature.
Installation in the GAC works like in the previous exercise. But this actually does not work here!
Only after we (delay-)signed the assembly with

sn /R MyLib.dll mykeys.snk

installation works as before.