C++/CLI strong named assemblies in Visual Studio 2010

In a previous post, we saw how to give a C++/CLI assembly a strong name in Visual Studio 2008. On VS 2010, this doesn't work quite the same way; a fix is meant to come in a future service pack.

Meanwhile, the new way to do this is as follows:

  1. In Solution Explorer, right-click the project, then go to Properties->Linker->Advanced->Key File, and select the .snk file generated with sn.exe.
  2. In the same place (Linker->Advanced), set the Delay Sign property to Yes.
  3. Add the following Post Build Event to the project: sn -R <dll> <key file>
  4. To achieve the previous, some macros sus as $(ProjectDir) are useful. Use as needed. In my case, the post build event ended up being this::

    
    "$(FrameworkSDKRoot)"bin\sn -R $(SolutionDir)Debug\NombreDLL.dll $(ProjectDir)NombreDLL.snk
    
    

    I used the SolutionDir macro because in my particular project, the compiled dll is saved to the solution's Debug folder (for release builds, the Release folder). And the key file is inside the project, hence the ProjectDir macro.

References: Social MSDN post where I saw this

Comments

Popular posts from this blog

VB.NET: Raise base class events from a derived class

Apache Kafka - I - High level architecture and concepts

Upgrading Lodash from 3.x to 4.x