Re: Easiest way to get Strong Name? by WilliamSullivan
WilliamSullivan
Tue Apr 18 15:36:29 CDT 2006
True, true. And that's what I did. Thanks.
"Nicole Calinoiu" wrote:
> 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" <WilliamSullivan@discussions.microsoft.com> wrote in
> message news:9C1201A0-CBAF-4C1A-9482-45974AF8A087@microsoft.com...
> > 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...
> >
> > "Cerebrus" wrote:
> >
> >> 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.
> >>
> >>
>
>