Wednesday, June 22, 2005

Enterprise Library Tips for Strong Names and Versions

[This was originally posted at http://timstall.dotnetdevelopersjournal.com/enterprise_library_tips_for_strong_names_and_versions.htm]

Previously I offered some tips for configuring Enterprise Library. Today I'll discuss another problematic area - adding strong names.

First, this builds on concepts about Strong Names and PublicKeyTokens.  You may need to add a strong name to the EntLib blocks if you include it in a project that already uses strong names (because this requires that all assemblies being referenced also have strong names).

To add a strong name, you'll need to create a key and reference it in the AssemblyInfo.cs file.

Strong Names and Versioning Tips

0 - You will need to add the key to the source code. Microsoft gives us the source code partially so that we can do things like this.

1 - Put properties (like strong-naming) in the GlobalAssemblyInfo.cs. This requires you to remove (or comment out) the key from the other 38 AssemblyInfo files, however it lets you change it in one place.

2 - Note that there are two places that DLLs are stored.

  • C:\Program Files\Microsoft Enterprise Library\bin
  • C:\Program Files\Microsoft Enterprise Library\src\\bin

Opening the EntLib solution and compiling creates copies in the \src dir. You still need to copy these to the \bin
Make sure to run the "Copy Assemblies to Bin Directory" script included in the EntLib start menu. If you're not putting DLLs in the GAC,  EntLib's config tool pulls DLLs from the \bin dir. So you'll notice strong-name nightmares if you don't do this. It will set the assembly name (like PublicKeyToken) from those DLLs, not merely the ones used in your project. For example, check the version of the DLLs loaded by the config tool, and make sure that they include the strong name.

No comments:

Post a Comment