Display Assembly Version Information - InfoPath Dev
in

InfoPath Dev

Display Assembly Version Information

Last post 01-02-2010 05:37 AM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-23-2009 09:52 AM

    Display Assembly Version Information

    For anyone that's interested....

    At times.....it's nice to have the version number of your code displayed someplace for the purposes of quickly identifying the "build" of the form. That is of course if you have managed code associated with your form. Here's one way of accomplishing this or how I implemented such a thing.

    In your code....  C#  you have to include the System.Reflection assembly such as...         
    using System.Reflection;

     I placed a textbox on my form and added the following code in the FormEvents_Loading() event:


    XPathNavigator root = MainDataSource.CreateNavigator(); 

    Assembly a = Assembly.GetExecutionAssembly();
    AssemblyName an = a.GetName();
    Version v = an.Version;
    root.SelectSingleNode("//my:txtVersion", NamespaceManager).SetValue("Ver:" + v.Major + "." + v.Minor + "." + v.Revision);

    You can manipulate the assembly version to your hearts content in the AssemblyInfo.cs file that's part of your Visual Studio project. In that file you'll see

    [assembly: AssemblyVersion(1.0.0.0)]

    The numbers are all explained in that file. Meaning what those numbers represent. That being the Major and Minor versions, Build and Revision numbers. 

    One caveat to all this. If you plan to hardcode your number such as 1.0.0.0 and so forth. Each time you publish your form, you'll have to manualy change one of those numbers, build and then publish. Otherwise, Sharepoint is going to complain the same version exists. One way around all that is to use a wildcard in your numbering such as

    [assembly: AssemblyVersion(1.0.*)]

     

     

  • 01-02-2010 05:37 AM In reply to

    Re: Display Assembly Version Information

    Reflection is great, no? Thanks for publishing the tip!

    Hilary Stoupa

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.