PDA

View Full Version : Strong naming



ivan.peter
Mar 19, 2008, 5:59 AM
Hello devs,

I*like*your Coolite assembly. I went to use it in my project, but the assembly is not strong named. WHY?
Are you going to sing it*in*the*next*release?*When*is*it*going*to*be?

Thanks, Peter

geoffrey.mcgill
Mar 19, 2008, 3:02 PM
Hi Peter,

I investigated this issue and it looks like some kind of problem happens when we combine the .dll's in our final build process. We use a build tool called ILMerge (http://tinyurl.com/9xuqf) to combine three .dll's into one, all of which are properly Strong Named before the merge, but for some reason the .snk does not get applied to the final merged .dll.

We're trying a few things to get this to work. If all else fails, we'll include all three .dll's individually with the next release. Come to think of it, that would not be a bad idea anyways.

I should have another update for you very shortly.

geoffrey.mcgill
Mar 19, 2008, 5:33 PM
Ok, I found the problem and fixed it.

Just in case anyone finds this post in the future and wonders what was going wrong...

In order to get ILMerge to StrongName your final merged Assembly, you have to set the /keyfile command line argument to point to the .snk that ILMerge will use to for the final combined .dll.

Example


/keyfile:"$(ProjectDir)Properties\Coolite.Web.UI.snk"


Hope this helps.

This updated strong named .dll will be available with version 0.4.1 (or higher).

geoffrey.mcgill
Mar 20, 2008, 12:31 AM
For interest sake, here's a quick little script for determining if an Assembly has been Strong Named or not.

The following blog post is the source of this code and has more information.

http://www.dotnet-blog.com/index.php/2007/07/11/c-detect-if-an-assembly-is-strong-named-or-not/

Example


<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Assembly assembly = Assembly.GetAssembly(typeof(Coolite.Web.UI.ScriptM anager));
if (assembly != null)
{
AssemblyName name = assembly.GetName();
byte[] key = name.GetPublicKey();
bool isSigned = key.Length > 0;
Response.Write(string.Format("Is Signed: {0}", isSigned));
}
}
</script>

ivan.peter
Mar 20, 2008, 4:02 AM
Yes, there are other ways to find out whether an assembly has been strong named (based on looking for the public key):


"C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn.exe" -T assembly.dll
- of course, you can use a different version of .Net SDK.

I wouldn't mind if you released just one dll, but please, sign it.

geoffrey.mcgill
Mar 20, 2008, 1:57 PM
The version 0.4.1 build has been released (http://www.ext.net/download/).

This build includes a single combined Coolite.Web.UI.dll file which has been signed properly.

Hope this helps.

ivan.peter
Mar 25, 2008, 4:21 AM
Thank*you,*now it*works*nicely.*Peter*