Assigning a strong name to the yfiles.NET assemblies

Tips & Tricks

Summary

This article shows how to assign a strong name to the assemblies from the yfiles.NET or yfiles WPF distributions.

Description

This article assumes some basic knowledge about strong names in the .NET context. If you are unfamiliar with this matter, an excellent introduction can be found at ONDotnet.com: The Secrets of Strong Naming.

The assemblies from the yFiles.NET / yFiles WPF distribution are not strongly named. This is intentional, since you are required to to obfuscate yfiles.NET prior to distribution. However, this obfuscation step invalidates any strong name assigned previously, thus resulting in an unusable library. Simply resigning the assemblies with our strong name key is not possible for you, since you'd need access to the private key from our keypair.

Therefore, if you need to have strongly named yFiles assemblies (e.g. if you are building a strongly named application), you have to sign the assemblies with your own company key. This step is usually part of the build process of an assembly, so the usual methods (e.g. source attributes, al.exe, sn -R) won't work here. However, you can resort to freely available third party tools.

Using StrongNameSigner.exe

You can use the freely available StrongNameSigner tool for this purpose. This tool offers both a GUI as well as a command line interface and an API for integration into build engines. Please see the documentation for integration as a MSBuild target.

Make sure you are using the officially released version of this tool, either the NuGet package or the installer

  1. Open the Visual Studio Command prompt or otherwise make sure that your PATH includes the .NET SDK binaries, and change to the directory where you want to perform the signing.
  2. Create two directories unsigned and signed and copy the yFiles assemblies you want to sign to the unsigned directory
  3. In a command window, execute:
    C:\Program Files\BrutalDev.NET Assembly Strong-Name Signer\StrongNameSigner.Console.exe -in .\unsigned -out .\signed -k YOUR_KEY_FILE.snk
  4. The resulting assemblies will be placed in the signed directory and should now have a valid strong name from your company key. You can check this with:
    sn -T signed\yfilesAlgorithms.dll
    The public key token must match the token of your public key.
The assemblies are now signed with your company key and can be used like any strongly named assembly.

You must rebuild your application against the signed assemblies, since the license mechanism evaluates strong name information, e.g. the embedded license information in your application is rendered invalid if you exchange the unsigned assemblies by signes ones.
Since obfuscation invalidates this strong name, you have to resign the assemblies after obfuscation, using your private key (most obfuscators provide an option for that), or sign the assemblies only after the final obfuscation.
Both Signer and StrongNameSigner are third party tools and are neither created or distributed by yWorks nor an official part of the .NET framework SDK. Therefore, these steps are presented on an as-is basis without warranty of any kind. Especially, you should always backup your existing yFiles.NET assemblies before executing these steps. Also, we cannot guarantee that each version of these tools will be able to process each release of the dll correctly.
Note that the InternalsVisibleTo attribute for friend assemblies has to include the public key of the signed assembly, otherwise accessing internal members from friend assemblies won't work. This most prominently affects the CreateLayerConstraintFactory and CreateSequenceConstraintFactory. The current version of StrongNameSigner will make this adjustment automatically if you sign all assemblies at once.

Resources

Categories this article belongs to:
yFiles for Silverlight > Deployment
yFiles WPF > Deployment
yFiles.NET > Deployment
Applies to:
yFiles.NET: 4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6
yFiles WPF: 1.0, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6
yFiles for Silverlight: 1.0, 2.0, 2.1, 2.2, 2.3
Keywords:
assemblies - strong name - Signer - StrongNameSigner