Strong-Name Verification at Runtime

When strong-named assemblies are referenced, the CLR is put in a mode where it pays extra attention to integrity of dependencies. When the runtime locates assemblies, it makes sure the strong name matches exactly what the assembly manifest refers to. If not, an exception is triggered.

As an exercise, change the version number of the calc.dll assembly by tweaking the AssemblyVersion attribute and recompiling calc.dll:

// Calc.csusing System.Reflection;[assembly: AssemblyVersion("2.0.0.0")]public static class Calc{    public static int Add(int a, int b)    {        return a + b;    }}

Don’t recompile program.exe and try to run it with the newer version of calc.dll sitting next to ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.