Assembly private name

From FlexRule Wiki
Jump to: navigation, search

Introduction

In some scenarios you would rather not to sign your assembly with any SNK key. But environment license requires a uniquely identifies you and your application. In these cases, you can use Assembly Private Name to assign an environment license to your application.

To avoid the strong name signing and use an SNK for your identifier and use Assembly Private Name you need to follow below steps:

  1. Create and SNK file
  2. Extract the public key token
    1. Extract public key file
    2. Generate public key token from public key file
  3. Send us the pubic key token and list of the assemblies that have the Private Name embedded
  4. Create/Generate Assembly Private Name for each assembly using the same SNK file
  5. Add the Assembly Private Name to the AssemblyInfo.cs for each individual assembly

SNK

Generate SNK file

SNK files are a pair of public/private keys that allows you sign your assembly. Also they are required for Assembly Private Name. To lear how to create an SNK file please visit Microsoft website. But in short, you can use sn.exe with the following format

sn.exe -k snk-file-name

Extract Public Key Token

To extract your public key token, you need to first extract your public key from SNK file.

sn -p snk-file-name public-key.snk

And then you can generate the public key token from your public key i.e. public-key.snk

sn -t public-key.snk

Private Assembly Utility

In your FlexRule Runtime location, open a command line and type the bellow command

FlexRule.Tester.exe -sign

Like the bellow picture:

Commnad-APV.png

and the following window appears:

Assembly-Private-Name.png

Embed Assembly Private Name

To sign your assembly using Assembly Private Name please follow below:

  1. Build your assembly without any change, just like a normal assembly
  2. Run the assembly private name utility (FlexRule.Tester.exe -sign)
  3. Browse your assembly
  4. Browse your SNK file
  5. Press Generate button
  6. The utility will generate a code in the bottom section, just copy and paste it into your Assembly.Info.cs class file of your project
  7. Rebuild your assembly

APN-sample.png

Please note, if your assembly name changes, you need to re-generate your Assembly Private Name.