Easiest way to get Strong Name?

G

Guest

Okay, somebody hands me a signed .NET assembly. What's the easiest way to
get its strong name WITHOUT writing a program to do it? I'm wondering if
there is a tool that will print out the strong name or something similar. I
was hoping I could get the strong name by right-clicking on the file and
searching through its properties, but no luck...
 
M

Michael Nemtsev

Hello William,

SN.EXE from the c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ ?

WS> Okay, somebody hands me a signed .NET assembly. What's the easiest
WS> way to get its strong name WITHOUT writing a program to do it? I'm
WS> wondering if there is a tool that will print out the strong name or
WS> something similar. I was hoping I could get the strong name by
WS> right-clicking on the file and searching through its properties, but
WS> no luck...
WS>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
C

Cerebrus

Hi William,

The Strong name tool (sn.exe), which can be invoked directly from the
VS.NET command prompt, gives you all the information related to strong
names.
sn.exe -v "MyAssembly.dll"
will tell you if an assembly is strong named or not.
sn.exe -Tp "MyAssembly.dll"
will output both the full Public Key (a v. long string) and the much
shorter Public Key token.
sn.exe -T "MyAssembly.dll"
will output only the Public Key token.
sn.exe -tp "MyKey.snk"
is run on the KeyFile and will also provide the same output. Note the
small -tp switch.

HTH,

Regards,

Cerebrus.
 
G

Guest

See... that's just it. No strong name. Just PARTS of the strong name. I'm
looking for an easy way to get the strong name of an assembly... As in,
"AssemblyName, Version=0.0.0.0, Culture=Neutral,
PublicKeyToken=1111111111111111". What SN gives you is bread crumbs that you
have to press together to make a retarded loaf. Chance of errors when doing
this? What do you think? I'm wondering if there is a tool already out there
that, when you hand it an assembly, hands you back the ENTIRE strong name.
Maybe even pastes it into the clipboard, I don't know... At a minimum it
would give you back, get this, not the PKT, not the version, not the culture,
but the whole shebang WHAM! Right there! Look, its the strong name of the
assembly! I can just copy the whole thing and paste it right into my
program, without any worries that I screwed up adding little pieces from this
place and that together...
 
N

Nicole Calinoiu

There's no such beastie in the SDK, although secutil.exe probably comes
closer to your needs than sn.exe, although it provides the full signing key
rather than the token that you would prefer. That said, it's really quite
trivial to write a little app to do this. e.g. (console app):

using System;
using System.Reflection;
using System.Windows.Forms;

namespace StrongNameReader
{
internal sealed class Program
{
[STAThread]
private static void Main(string[] args)
{
try
{
if (args.Length == 1)
{
string assemblyName =
Assembly.ReflectionOnlyLoadFrom(args[0]).FullName;
Clipboard.SetText(assemblyName);
Console.WriteLine(assemblyName);
}
else
{
if (args.Length == 0)
{
throw new ArgumentException("Please provide an assembly path");
}
else
{
throw new ArgumentException("Please provide one assembly path only.");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
 
G

Guest

True, true. And that's what I did. Thanks.

Nicole Calinoiu said:
There's no such beastie in the SDK, although secutil.exe probably comes
closer to your needs than sn.exe, although it provides the full signing key
rather than the token that you would prefer. That said, it's really quite
trivial to write a little app to do this. e.g. (console app):

using System;
using System.Reflection;
using System.Windows.Forms;

namespace StrongNameReader
{
internal sealed class Program
{
[STAThread]
private static void Main(string[] args)
{
try
{
if (args.Length == 1)
{
string assemblyName =
Assembly.ReflectionOnlyLoadFrom(args[0]).FullName;
Clipboard.SetText(assemblyName);
Console.WriteLine(assemblyName);
}
else
{
if (args.Length == 0)
{
throw new ArgumentException("Please provide an assembly path");
}
else
{
throw new ArgumentException("Please provide one assembly path only.");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}



William Sullivan said:
See... that's just it. No strong name. Just PARTS of the strong name.
I'm
looking for an easy way to get the strong name of an assembly... As in,
"AssemblyName, Version=0.0.0.0, Culture=Neutral,
PublicKeyToken=1111111111111111". What SN gives you is bread crumbs that
you
have to press together to make a retarded loaf. Chance of errors when
doing
this? What do you think? I'm wondering if there is a tool already out
there
that, when you hand it an assembly, hands you back the ENTIRE strong name.
Maybe even pastes it into the clipboard, I don't know... At a minimum it
would give you back, get this, not the PKT, not the version, not the
culture,
but the whole shebang WHAM! Right there! Look, its the strong name of
the
assembly! I can just copy the whole thing and paste it right into my
program, without any worries that I screwed up adding little pieces from
this
place and that together...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top