How do I get version resources from the executing assembly?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank T. Clark

    How do I get version resources from the executing assembly?

    I am having trouble trying to retrieve the version resources of the
    executing assembly at runtime. I want to retrieve AssemblyTitle,
    AssemblyDescrip tion, AssemblyCompany , AssemblyProduct , and
    AssemblyCopyrig ht.I assume it has something to do with GetExecutingAss embly.
    What am I missing? A line or two of sample code is greatly appreciated.
    Thank you.


  • Stefan

    #2
    Re: How do I get version resources from the executing assembly?

    Hi Frank
    use
    System.Reflecti on.Assembly oAssembly =
    System.Reflecti on.Assembly.Get ExecutingAssemb ly();
    System.Diagnost ics.FileVersion Info oFileVersionInf o =
    FileVersionInfo .GetVersionInfo (oAssembly.Loca tion);
    oFileVersionInf o.FileMajorPart , oFileVersionInf o.FileMinorPart

    "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
    news:ebbp%231Zj DHA.2364@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > I am having trouble trying to retrieve the version resources of the
    > executing assembly at runtime. I want to retrieve AssemblyTitle,
    > AssemblyDescrip tion, AssemblyCompany , AssemblyProduct , and
    > AssemblyCopyrig ht.I assume it has something to do with[/color]
    GetExecutingAss embly.[color=blue]
    > What am I missing? A line or two of sample code is greatly appreciated.
    > Thank you.
    >
    >[/color]


    Comment

    • Frank T. Clark

      #3
      Re: How do I get version resources from the executing assembly?

      Thanks. As I have often said. The answer is simple, once you know the
      answer.

      "Stefan" <shogun@steffsw orld.ch> wrote in message
      news:ekwIF4ZjDH A.1884@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Hi Frank
      > use
      > System.Reflecti on.Assembly oAssembly =
      > System.Reflecti on.Assembly.Get ExecutingAssemb ly();
      > System.Diagnost ics.FileVersion Info oFileVersionInf o =
      > FileVersionInfo .GetVersionInfo (oAssembly.Loca tion);
      > oFileVersionInf o.FileMajorPart , oFileVersionInf o.FileMinorPart
      >
      > "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
      > news:ebbp%231Zj DHA.2364@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > I am having trouble trying to retrieve the version resources of the
      > > executing assembly at runtime. I want to retrieve AssemblyTitle,
      > > AssemblyDescrip tion, AssemblyCompany , AssemblyProduct , and
      > > AssemblyCopyrig ht.I assume it has something to do with[/color]
      > GetExecutingAss embly.[color=green]
      > > What am I missing? A line or two of sample code is greatly appreciated.
      > > Thank you.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Mattias Sjögren

        #4
        Re: How do I get version resources from the executing assembly?

        [color=blue]
        >System.Reflect ion.Assembly oAssembly =
        >System.Reflect ion.Assembly.Ge tExecutingAssem bly();[/color]

        From there on, I'd use oAssembly.GetNa me().Version and
        oAssembly.GetCu stomAttributes( ) instead to retrieve the information.



        Mattias

        --
        Mattias Sjögren [MVP] mattias @ mvps.org

        Please reply only to the newsgroup.

        Comment

        • Frank T. Clark

          #5
          Re: How do I get version resources from the executing assembly?

          A cross-reference for anyone who finds it useful.

          // FileVersionInfo .Comments = AssemblyDescrip tion

          // FileVersionInfo .CompanyName = AssemblyCompany

          // FileVersionInfo .FileDescriptio n = AssemblyTitle

          // FileVersionInfo .FileVersion = AssemblyFileVer sion

          // FileVersionInfo .LegalCopyright = AssemblyCopyrig ht

          // FileVersionInfo .LegalTrademark s = AssemblyTradema rk

          // FileVersionInfo .ProductName = AssemblyProduct

          // FileVersionInfo .ProductVersion = AssemblyInforma tionalVersion


          "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
          news:uBYQOjajDH A.2244@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Thanks. As I have often said. The answer is simple, once you know the
          > answer.
          >
          > "Stefan" <shogun@steffsw orld.ch> wrote in message
          > news:ekwIF4ZjDH A.1884@TK2MSFTN GP09.phx.gbl...[color=green]
          > > Hi Frank
          > > use
          > > System.Reflecti on.Assembly oAssembly =
          > > System.Reflecti on.Assembly.Get ExecutingAssemb ly();
          > > System.Diagnost ics.FileVersion Info oFileVersionInf o =
          > > FileVersionInfo .GetVersionInfo (oAssembly.Loca tion);
          > > oFileVersionInf o.FileMajorPart , oFileVersionInf o.FileMinorPart
          > >
          > > "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
          > > news:ebbp%231Zj DHA.2364@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
          > > > I am having trouble trying to retrieve the version resources of the
          > > > executing assembly at runtime. I want to retrieve AssemblyTitle,
          > > > AssemblyDescrip tion, AssemblyCompany , AssemblyProduct , and
          > > > AssemblyCopyrig ht.I assume it has something to do with[/color]
          > > GetExecutingAss embly.[color=darkred]
          > > > What am I missing? A line or two of sample code is greatly[/color][/color][/color]
          appreciated.[color=blue][color=green][color=darkred]
          > > > Thank you.
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Frank T. Clark

            #6
            Re: How do I get version resources from the executing assembly?

            I am sorry, but I do not find sufficient information in your answer to
            implement it.

            oAssembly.GetCu stomAttributes (?).?

            "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
            news:uiefrvajDH A.2616@TK2MSFTN GP11.phx.gbl...[color=blue]
            >[color=green]
            > >System.Reflect ion.Assembly oAssembly =
            > >System.Reflect ion.Assembly.Ge tExecutingAssem bly();[/color]
            >
            > From there on, I'd use oAssembly.GetNa me().Version and
            > oAssembly.GetCu stomAttributes( ) instead to retrieve the information.
            >
            >
            >
            > Mattias
            >
            > --
            > Mattias Sjögren [MVP] mattias @ mvps.org
            > http://www.msjogren.net/dotnet/
            > Please reply only to the newsgroup.[/color]


            Comment

            • Mattias Sjögren

              #7
              Re: How do I get version resources from the executing assembly?

              Frank,
              [color=blue]
              >I am sorry, but I do not find sufficient information in your answer to
              >implement it.
              >
              >oAssembly.GetC ustomAttributes (?).?[/color]

              If you for example are looking for the AssemblyTitleAt tribute:

              object[] attrs =
              oAssembly.GetCu stomAttributes( typeof(Assembly TitleAttribute) );
              if ( atts.Length > 0 ) {
              AssemblyTitleAt tribute ata = atts[0] as AssemblyTitleAt tribute;
              ...
              }



              Mattias

              --
              Mattias Sjögren [MVP] mattias @ mvps.org

              Please reply only to the newsgroup.

              Comment

              Working...