Programatically getting my AssemblyVersion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • herc

    #1

    Programatically getting my AssemblyVersion

    How does one get the AssemblyVersion of the currently excuting
    assembly? At first glance, it would appear that this would give you
    the AsseblyName which will give you the version:

    string appName =
    AppDomain.Curre ntDomain.SetupI nformation.Appl icationName;
    AssemblyName assemblyName = AssemblyName.Ge tAssemblyName(a ppName);

    But the appname is <name>.vshost.e xe. Is there any way to find out the
    name of the assembly minus the vshost?

  • herc

    #2
    Re: Programatically getting my AssemblyVersion

    The answer:

    string appName = Assembly.GetAss embly(this.GetT ype()).Location ;
    AssemblyName assemblyName = AssemblyName.Ge tAssemblyName(a ppName);
    return assemblyName.Ve rsion.ToString( );

    Comment

    • Mattias Sjögren

      #3
      Re: Programatically getting my AssemblyVersion

      >string appName = Assembly.GetAss embly(this.GetT ype()).Location ;[color=blue]
      >AssemblyName assemblyName = AssemblyName.Ge tAssemblyName(a ppName);
      >return assemblyName.Ve rsion.ToString( );[/color]

      Or just

      return this.GetType(). Assembly.GetNam e().Version.ToS tring();


      Mattias

      --
      Mattias Sjögren [C# MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • Ignacio Machin \( .NET/ C# MVP \)

        #4
        Re: Programatically getting my AssemblyVersion

        Hi,

        "herc" <cartoper@gmail .com> wrote in message
        news:1140549489 .434496.168910@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > The answer:
        >
        > string appName = Assembly.GetAss embly(this.GetT ype()).Location ;
        > AssemblyName assemblyName = AssemblyName.Ge tAssemblyName(a ppName);
        > return assemblyName.Ve rsion.ToString( );
        >[/color]

        A shorter way:

        Assembly.GetExe cutingAssembly( ).GetName.Versi on.ToString()



        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation


        Comment

        Working...