File Version

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis C. Drumm

    File Version

    I am trying to find a way to compare the version of the currently executing
    assembly to the version of my latest upload so I can notify the user when a
    newer version is available.

    Is it possible to get the version information programmaticall y for an exe
    file in some folder on my web site or alternatively to retrieve the version
    information from information appearing on a web page on my web site?

    Thanks,

    Dennis


  • Steve Goodyear

    #2
    RE: File Version

    Hi Dennis,
    You can retrieve the Version object which contains the Major, Minor, Build,
    and Revision properties of the assembly version.

    Cheers,
    Steve Goodyear

    System.Version version =
    System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). Version;
    MessageBox.Show (version.ToStri ng());

    Comment

    • Dennis C. Drumm

      #3
      Re: File Version

      Steve:

      Thanks, but I knew that! What I had asked is how to retrieve the file
      version of an exe from my server (the bundled install program) or how to
      read some text from a page on my web site that contains version information
      for the latest build.

      Of course, I suppose I could embed the file version in a simple ascii text
      file on my server and read that, but then that is one more thing that must
      be remembered every time an upload is done.

      Thanks,

      Dennis


      "Steve Goodyear" <SteveGoodyear@ discussions.mic rosoft.com> wrote in message
      news:02D2A5AC-F745-408C-A910-2EDA79585549@mi crosoft.com...[color=blue]
      > Hi Dennis,
      > You can retrieve the Version object which contains the Major, Minor,
      > Build,
      > and Revision properties of the assembly version.
      >
      > Cheers,
      > Steve Goodyear
      >
      > System.Version version =
      > System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). Version;
      > MessageBox.Show (version.ToStri ng());[/color]


      Comment

      • Steven Cheng[MSFT]

        #4
        Re: File Version

        Hi Dennis,

        As for the
        =============== ====
        how to read some text from a page on my web site that contains version
        information for the latest build.
        =============== ====

        do you mean that you'd like to provide a dynamic web page on your
        webserver(IIS) which will return the components/application's update list
        info? If so, I think it's a good idea and you can consider define your
        update info as xml data so that the web page can return xml document to
        client (contentType="t ext/xml").

        Then, in the clientside, we can use the HttpWebRequest class (under
        System.Net namespace) to retrieve the xml data from that web page). How do
        you think of this? If you feel it's a possbile approach, I can paste some
        sample code on using HttpWebRequest component to get response text from a
        remote page.

        Thanks,

        Steven Cheng
        Microsoft Online Support

        Get Secure! www.microsoft.com/security
        (This posting is provided "AS IS", with no warranties, and confers no
        rights.)

        Comment

        • Dennis C. Drumm

          #5
          Re: File Version

          Steven:

          My preference would be to get the version information for the setup.exe file
          I upload to my web site for users to download. The setup.exe file is a
          compressed setup file that contains all the dll and exe files
          (assemblies)nec essary for the program.

          If that is not possible, then another method would need to be employed, such
          as you mention. I have not worked with dynamic web pages, so I really can't
          say if that will do or not. I will do some reading on that subject.

          How about just reading a user variable property, a custom metadata element)
          that I set for the downloads.htm web page of my site? Can I read that data
          remotely? If so, it would be easy to set a value named Version and provide
          its value every time I upload a new version.

          Again, I would prefer to get that information directly from the uploaded
          file it at all possible.

          Thanks,

          Dennis


          "Steven Cheng[MSFT]" <v-schang@online.m icrosoft.com> wrote in message
          news:uca0591XFH A.3052@TK2MSFTN GXA01.phx.gbl.. .[color=blue]
          > Hi Dennis,
          >
          > As for the
          > =============== ====
          > how to read some text from a page on my web site that contains version
          > information for the latest build.
          > =============== ====
          >
          > do you mean that you'd like to provide a dynamic web page on your
          > webserver(IIS) which will return the components/application's update list
          > info? If so, I think it's a good idea and you can consider define your
          > update info as xml data so that the web page can return xml document to
          > client (contentType="t ext/xml").
          >
          > Then, in the clientside, we can use the HttpWebRequest class (under
          > System.Net namespace) to retrieve the xml data from that web page). How do
          > you think of this? If you feel it's a possbile approach, I can paste some
          > sample code on using HttpWebRequest component to get response text from a
          > remote page.
          >
          > Thanks,
          >
          > Steven Cheng
          > Microsoft Online Support
          >
          > Get Secure! www.microsoft.com/security
          > (This posting is provided "AS IS", with no warranties, and confers no
          > rights.)
          >[/color]


          Comment

          • Steven Cheng[MSFT]

            #6
            Re: File Version

            Hi Dennis,

            Thanks for your reply. Actually the reason why I suggest use a page or
            document to publish your application's update list is because the client
            users are remote to the server you upload your setup package. So even if we
            can easily get the version info from the setup package, we need to download
            the setup package first( this will cause addiontal network transport. Also,
            even we get the setup package download, we can't directly get info from the
            package, we need to programmaticall y uncompressed the package and check
            version from the file(such as asssemblies) in it. So I think using a text
            format on the server and let the client applicaiton to request that text
            file to get the latest update list info is the reasonable approach. In
            .net, we can finish this through the following steps:

            1. Put a xml static file on the server which contains the update list info
            of your application/components

            2. In client application, use the .net's HttpWebRequest component to get
            the xml document on the remote server and load into a XmlDocument class

            3. Use XPath to query the version information in the xmldocument and
            determine whether to download update files or not.

            How do you think of this? If you feel necessary I can post some sample code
            snippet on this.

            Thanks,

            Steven Cheng
            Microsoft Online Support

            Get Secure! www.microsoft.com/security
            (This posting is provided "AS IS", with no warranties, and confers no
            rights.)

            Comment

            • Dennis C. Drumm

              #7
              Re: File Version

              Steven:

              Yes, please show me some code snippets to extract version information from
              an xml file.

              Thanks,

              Dennis


              "Steven Cheng[MSFT]" <v-schang@online.m icrosoft.com> wrote in message
              news:y%23pAPVAY FHA.1940@TK2MSF TNGXA01.phx.gbl ...[color=blue]
              > Hi Dennis,
              >
              > Thanks for your reply. Actually the reason why I suggest use a page or
              > document to publish your application's update list is because the client
              > users are remote to the server you upload your setup package. So even if
              > we
              > can easily get the version info from the setup package, we need to
              > download
              > the setup package first( this will cause addiontal network transport.
              > Also,
              > even we get the setup package download, we can't directly get info from
              > the
              > package, we need to programmaticall y uncompressed the package and check
              > version from the file(such as asssemblies) in it. So I think using a text
              > format on the server and let the client applicaiton to request that text
              > file to get the latest update list info is the reasonable approach. In
              > net, we can finish this through the following steps:
              >
              > 1. Put a xml static file on the server which contains the update list info
              > of your application/components
              >
              > 2. In client application, use the .net's HttpWebRequest component to get
              > the xml document on the remote server and load into a XmlDocument class
              >
              > 3. Use XPath to query the version information in the xmldocument and
              > determine whether to download update files or not.
              >
              > How do you think of this? If you feel necessary I can post some sample
              > code
              > snippet on this.
              >
              > Thanks,
              >
              > Steven Cheng
              > Microsoft Online Support
              >
              > Get Secure! www.microsoft.com/security
              > (This posting is provided "AS IS", with no warranties, and confers no
              > rights.)
              >[/color]


              Comment

              • Steven Cheng[MSFT]

                #8
                Re: File Version

                Hi Dennis,

                The reason I suggest XML file is because XML file provide well-formed
                structure for storing and representing data and the classes under
                System.Xml namespace has provide sufficient interfaces for us to process
                XML data. For example, we have the following format of version info:

                =============== ==
                <?xml version="1.0" encoding="utf-8" ?>
                <versionInfo>
                <latest version="1.0.4. 438">
                <assemblies>
                <assembly fullName="Syste m.Data, Version=1.0.241 1.0, Culture=neutral ,
                PublicKeyToken= b77a5c561934e08 9" />
                <package location="http://servername/downloaddir/myapp104438.zip " />
                </assemblies>
                </latest>
                </versionInfo>
                =============== =====

                the file is located at


                Then we can use the following


                =============== ====
                string url=
                "http://sha-schost-01/StevenRoot/SearchFriendApp/updateinfo/version.xml";
                XmlDocument doc = null;

                try
                {

                doc = new XmlDocument();
                doc.Load(url);

                XmlElement latestVersion = doc.SelectSingl eNode("//latest") as XmlElement;
                //display the version attribute's value
                MessageBox.Show ( latestVersion.A ttributes["version"].Value
                );

                }
                catch(System.Ne t.WebException webex)
                {
                txtResponse.Tex t += "\r\n" + webex.ToString( );
                }
                catch(Exception ex)
                {
                txtResponse.Tex t += "\r\n" + ex.ToString();
                }
                finally
                {
                sr.Close();
                }
                =============== ======

                Hope helps. Thanks,

                Steven Cheng
                Microsoft Online Support

                Get Secure! www.microsoft.com/security
                (This posting is provided "AS IS", with no warranties, and confers no
                rights.)

                Comment

                • Dennis C. Drumm

                  #9
                  Re: File Version

                  Steven:

                  That is a geat help!

                  But, I was expecting something about the use of HttpWebRequest as mentioned
                  in your last two posts.

                  Also you have a line sr.Close(). What is sr?

                  Thanks,

                  Dennis

                  "Steven Cheng[MSFT]" <v-schang@online.m icrosoft.com> wrote in message
                  news:IypeYFPYFH A.3928@TK2MSFTN GXA01.phx.gbl.. .[color=blue]
                  > Hi Dennis,
                  >
                  > The reason I suggest XML file is because XML file provide well-formed
                  > structure for storing and representing data and the classes under
                  > System.Xml namespace has provide sufficient interfaces for us to process
                  > XML data. For example, we have the following format of version info:
                  >
                  > =============== ==
                  > <?xml version="1.0" encoding="utf-8" ?>
                  > <versionInfo>
                  > <latest version="1.0.4. 438">
                  > <assemblies>
                  > <assembly fullName="Syste m.Data, Version=1.0.241 1.0, Culture=neutral ,
                  > PublicKeyToken= b77a5c561934e08 9" />
                  > <package location="http://servername/downloaddir/myapp104438.zip " />
                  > </assemblies>
                  > </latest>
                  > </versionInfo>
                  > =============== =====
                  >
                  > the file is located at
                  > http://sha-schost-01/StevenRoot/Sear...fo/version.xml
                  >
                  > Then we can use the following
                  >
                  >
                  > =============== ====
                  > string url=
                  > "http://sha-schost-01/StevenRoot/SearchFriendApp/updateinfo/version.xml";
                  > XmlDocument doc = null;
                  >
                  > try
                  > {
                  >
                  > doc = new XmlDocument();
                  > doc.Load(url);
                  >
                  > XmlElement latestVersion = doc.SelectSingl eNode("//latest") as XmlElement;
                  > //display the version attribute's value
                  > MessageBox.Show ( latestVersion.A ttributes["version"].Value
                  > );
                  >
                  > }
                  > catch(System.Ne t.WebException webex)
                  > {
                  > txtResponse.Tex t += "\r\n" + webex.ToString( );
                  > }
                  > catch(Exception ex)
                  > {
                  > txtResponse.Tex t += "\r\n" + ex.ToString();
                  > }
                  > finally
                  > {
                  > sr.Close();
                  > }
                  > =============== ======
                  >
                  > Hope helps. Thanks,
                  >
                  > Steven Cheng
                  > Microsoft Online Support
                  >
                  > Get Secure! www.microsoft.com/security
                  > (This posting is provided "AS IS", with no warranties, and confers no
                  > rights.)
                  >[/color]


                  Comment

                  • Steven Cheng[MSFT]

                    #10
                    Re: File Version

                    Thanks for your response Dennis,

                    You're a sharp guy :-). Actually, I did use the HttpWebRequest in the demo
                    code at first, however since using XmlDocument.Loa d method is much more
                    convenient and clear, so I changed to that(the sr is an instance of
                    StreamReader ). Well, I've pasted the complete code of using
                    HttpWebRequest to retrieve the xml stream from server, also using
                    httpWebRequest is not restricted to Xml document, we can retrieve any
                    static content/ dynamic document from server by it.

                    =============== ==============
                    private void btnReadUpdate_C lick(object sender, System.EventArg s e)
                    {

                    HttpWebRequest webreq = null;
                    HttpWebResponse webrep = null;
                    StreamReader sr = null;
                    string url= "http://servername/dirname/version.xml";
                    XmlDocument doc = null;


                    try
                    {
                    webreq = WebRequest.Crea te(url) as HttpWebRequest;
                    webrep = webreq.GetRespo nse() as HttpWebResponse ;
                    sr = new
                    StreamReader(we brep.GetRespons eStream(),Syste m.Text.Encoding .UTF8);


                    doc = new XmlDocument();
                    doc.Load(sr);

                    XmlElement latestVersion = doc.SelectSingl eNode("//latest") as
                    XmlElement;


                    txtResponse.Tex t += "\r\n" + latestVersion.A ttributes["version"].Value;
                    }
                    catch(System.Ne t.WebException webex)
                    {
                    txtResponse.Tex t += "\r\n" + webex.ToString( );
                    }
                    catch(Exception ex)
                    {
                    txtResponse.Tex t += "\r\n" + ex.ToString();
                    }
                    finally
                    {
                    sr.Close();
                    }
                    }
                    =============== =========

                    Thanks & Regards,

                    Steven Cheng
                    Microsoft Online Support

                    Get Secure! www.microsoft.com/security
                    (This posting is provided "AS IS", with no warranties, and confers no
                    rights.)



                    Comment

                    • Dennis C. Drumm

                      #11
                      Re: File Version

                      Steven:]

                      Thank you very much, between what I was able to get from some google
                      searches and the stuff you have provided, it has given me a jump start into
                      xml, which is a new thing for me!!

                      Dennis


                      "Steven Cheng[MSFT]" <v-schang@online.m icrosoft.com> wrote in message
                      news:xe9J5$YYFH A.388@TK2MSFTNG XA01.phx.gbl...[color=blue]
                      > Thanks for your response Dennis,
                      >
                      > You're a sharp guy :-). Actually, I did use the HttpWebRequest in the
                      > demo
                      > code at first, however since using XmlDocument.Loa d method is much more
                      > convenient and clear, so I changed to that(the sr is an instance of
                      > StreamReader ). Well, I've pasted the complete code of using
                      > HttpWebRequest to retrieve the xml stream from server, also using
                      > httpWebRequest is not restricted to Xml document, we can retrieve any
                      > static content/ dynamic document from server by it.
                      >
                      > =============== ==============
                      > private void btnReadUpdate_C lick(object sender, System.EventArg s e)
                      > {
                      >
                      > HttpWebRequest webreq = null;
                      > HttpWebResponse webrep = null;
                      > StreamReader sr = null;
                      > string url= "http://servername/dirname/version.xml";
                      > XmlDocument doc = null;
                      >
                      >
                      > try
                      > {
                      > webreq = WebRequest.Crea te(url) as HttpWebRequest;
                      > webrep = webreq.GetRespo nse() as HttpWebResponse ;
                      > sr = new
                      > StreamReader(we brep.GetRespons eStream(),Syste m.Text.Encoding .UTF8);
                      >
                      >
                      > doc = new XmlDocument();
                      > doc.Load(sr);
                      >
                      > XmlElement latestVersion = doc.SelectSingl eNode("//latest") as
                      > XmlElement;
                      >
                      >
                      > txtResponse.Tex t += "\r\n" + latestVersion.A ttributes["version"].Value;
                      > }
                      > catch(System.Ne t.WebException webex)
                      > {
                      > txtResponse.Tex t += "\r\n" + webex.ToString( );
                      > }
                      > catch(Exception ex)
                      > {
                      > txtResponse.Tex t += "\r\n" + ex.ToString();
                      > }
                      > finally
                      > {
                      > sr.Close();
                      > }
                      > }
                      > =============== =========
                      >
                      > Thanks & Regards,
                      >
                      > Steven Cheng
                      > Microsoft Online Support
                      >
                      > Get Secure! www.microsoft.com/security
                      > (This posting is provided "AS IS", with no warranties, and confers no
                      > rights.)
                      >
                      >
                      >[/color]


                      Comment

                      • Steven Cheng[MSFT]

                        #12
                        Re: File Version

                        You're welcome Dennis,

                        Also, for XML interfaces and components implemented in .net, you can refer
                        to the following start guide:

                        #Employing XML in the .NET Framework
                        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

                        ramework.asp?fr ame=true

                        Hope also helps. Good Luck!

                        Regards,

                        Steven Cheng
                        Microsoft Online Support

                        Get Secure! www.microsoft.com/security
                        (This posting is provided "AS IS", with no warranties, and confers no
                        rights.)

                        Comment

                        Working...