With this post, I start a short tutorial on using a proprietary  library (developed by  us with .NET Compact Framework 3.9) on Windows Embedded Compact 2013, from the signing of the assembly (for registration in the GAC) to a sample application project, through the realization of a component exposed by the Platform Builder (in catalog items) that we can include in the OS image trivially.

I will cover :

  1. How to sign an assembly;
  2. Creating a component for catalog items in Platform Builder;
  3. Distribution and inclusion of the component in the OS image;
  4. Support for application debugging for the example that will use the component;
  5. Development of a sample application;

I'll use my M2Mqtt (MQTT Client Library for. Net) project as a reference, assuming that it is the component that we want to include in the image, so that third parties can develop an application that uses it having already onboard on a target device with Windows Embedded Compact 2013 and .Net Compact Framework 3.9.

Signing : GAC, Public Key Token and Strong Name

Very often there is a need to include a proprietary  assembly (maybe a library developed by us) directly into a Windows Embedded Compact image, as it is included the .Net Compact Framework through the Platform Builder (just using the catalog items). In this way , the DLL will be located in the \ Windows folder of the target device (along with all the assemblies of the framework ) and will be used by  third party application just by registering it in the GAC (Global Assembly Cache ).

In the case of .NET Compact Framework to perform the verification of the assembly  loaded from the GAC, it is necessary that it is signed and has an associated Public Key Token . The Public Key  Token is a 64-bit hash of the public key  related to the private key  used to sign the assembly . It is useful to make a unique assembly so that two assemblies with the same name are considered distinct (which is why we talk about Strong Name). Using my  M2Mqtt library for .Net Compact Framework 3.9 as a reference, we’ll see what are the steps needed to sign the assembly.

Using the Strong Name Tool

For the first step, we have to generate a private/public keys pair and for this we can use the Strong Name Tool (sn.exe) that comes with Visual Studio. We have to launch the "Developer Command Prompt for VS2012" and execute the following command:

sn –k M2Mqtt.snk

Let’s sign the assembly

The next step is to use the previous .snk file to sign the assembly to generate a corresponding Public Key Token. Generally, a project based on. Net Framework has the tab "Signing" in the "Properties" window where you can select the file.

01_thumb1

In the case of a .Net Compact Framework 3.9 project, this tab is not available and it is necessary to modify the AssemblyInfo.cs file specifying the following line:

The .snk file must be placed in the same folder as project file (.csproj).

With this settings, we will have a signed assembly (in this case M2Mqtt.dll) at the end of the compilation process and we can inspect it using a tool such as Reflector from RedGate.

02_thumb3

Now we have a signed assembly that is ready to be included in the OS image.

In the next post we will see how it is possible to implement a component that is visible in the Platform Builder catalog items including our file and all its needed configuration.