CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    [RESOLVED] Accessing version info of my own app

    I am creating an About box for one of my apps that should reflect the version number of the app as specified in the AssemblyVersionAttribute in AssemblyInfo.cpp, preferably without requiring me to have to update the number in two distinct locations in parallel. The Application::ProductVersion propperty looked promising for that purpose, as I interpret the MSDN docs, but it seems to always return "1.0.0.0", regardless of what I set up in AssemblyInfo.cpp. Could there be anything typical that I might be doing wrong and/or any other way to access this information?

    In case that matters: I have only tried this with the debug build so far.

    BTW: What means "using the default values" for the build and revision numbers as it has been preset by the IDE by setting AssemblyVersionAttribute to "1.0.*"?

    I also would like to access what I have set up for AssemblyCopyrightAttribute in AssemblyInfo.cpp, but I haven't seen any (possible) way to do that at all.

    TIA
    Last edited by Eri523; June 24th, 2011 at 03:28 PM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Accessing version info of my own app

    For general .NET questions, not releated specifically to C++/CLI, it is better to ask in C# forum and translate an answer to C++/CLI.

  3. #3
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Accessing version info of my own app

    Thanks for redirecting me, Alex F.

    But I'm referring to AssemblyInfo.cpp and don't know the C# equivalent for that. Besides that, I have noticed that there are distinct Application classes for Windows Forms and WCF (in distinct namespaces) that significantly differ in their properties and am afraid of confusion when asking there.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Accessing version info of my own app

    C# project generated by Application Wizard has AssemblyInfo.cs file. In any case, the answer is somewere in Reflection and accessing current assembly attributes, this must be the same in all .NET languages.

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Resolved Re: Accessing version info of my own app

    Thanks for pointing me to the Reflection API. I initialy considered this to be a natural choice too, but then I thought using the Application object would be more straightforward.

    I still don't know why Application::ProductVersion doesn't give me the desired result, but this does:

    Code:
          String ^strVersion = Reflection::Assembly::GetExecutingAssembly()->FullName;
          strVersion = strVersion->Substring(strVersion->IndexOf("Version=") + 8);
          strVersion = strVersion->Substring(0, strVersion->IndexOf(','));
    It extracts the version from an assembly name string like "Kalender, Version=1.0.3930.14807, Culture=neutral, PublicKeyToken=null".

    I also have found the explanation of what it means to abbreviate the version spec using *: http://msdn.microsoft.com/en-us/libr...attribute.aspx.

    I still have not found a way to retrieve the copyright string in the Reflection API, simply because I've not yet looked for it. But even if it isn't there (what I consider to be unlikely) it wouldn't be too much pain: It doesn't change that frequently.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured