Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to get the current version's assembly number`

how to get the current version's assembly number`

Scheduled Pinned Locked Moved C#
announcementtutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pashitech
    wrote on last edited by
    #1

    hi i have devoloped windows application, i wanna update that perticular developed version with my current(yet to develop)windows application can u please let me know how to fine and compare the versions, i got my current(yet to develop-update version's) assembly by using Assembly.GetExecutingAssembly().ToString() but, i want knw the current deployed version's assembly name so that i can find and update if its lower version else give a prompt saying this is already updated version.. hope u got my requirement thnx in advance prashanth

    A 1 Reply Last reply
    0
    • P pashitech

      hi i have devoloped windows application, i wanna update that perticular developed version with my current(yet to develop)windows application can u please let me know how to fine and compare the versions, i got my current(yet to develop-update version's) assembly by using Assembly.GetExecutingAssembly().ToString() but, i want knw the current deployed version's assembly name so that i can find and update if its lower version else give a prompt saying this is already updated version.. hope u got my requirement thnx in advance prashanth

      A Offline
      A Offline
      Anil Ch
      wrote on last edited by
      #2

      Assembly myAssembly = Assembly.GetExecutingAssembly(); FileVersionInfo info = FileVersionInfo.GetVersionInfo(myAssembly.Location); // info.ProductVersion gives you the complete version. // fileVersionInfo also contains many other property for details. Hope this helps. Regards :)

      M 2 Replies Last reply
      0
      • A Anil Ch

        Assembly myAssembly = Assembly.GetExecutingAssembly(); FileVersionInfo info = FileVersionInfo.GetVersionInfo(myAssembly.Location); // info.ProductVersion gives you the complete version. // fileVersionInfo also contains many other property for details. Hope this helps. Regards :)

        M Offline
        M Offline
        mike montagne
        wrote on last edited by
        #3

        Nice to find an expert on an important function. y any chance, do you know if the following snippet is how to get the hinstance we should pass to Bitmap.FromResource()?

                       String s = "MT_ConfirmREFRESH";
                       IntPtr h = Process.GetCurrentProcess( ).Handle;
        
                       try
                            {
                            Glyph1.GMap = Bitmap.FromResource( h, s );
                            }
                       catch
                            {
                            throw new Exception( "Bitmap resource " + s + " not found from process handle " + h.ToString( ) + "." );
                            }
        

        Documentation indicates that hinstance is supposed to be "A handle to an instance of the executable file that contains the resource." The snippet is part of a method of a class belonging to a .DLL to which the resource(s) have been added by the visual Project.Properties... Add existing file... process. When this code fails, the FCL message only indicates that "the" (a) parameter is not valid. The resources ostensibly exist. I assume the handle value is the most probable candidate for the problem, unless there is some problem with the registration of the resources which I am not aware of. Much thanks, m

        1 Reply Last reply
        0
        • A Anil Ch

          Assembly myAssembly = Assembly.GetExecutingAssembly(); FileVersionInfo info = FileVersionInfo.GetVersionInfo(myAssembly.Location); // info.ProductVersion gives you the complete version. // fileVersionInfo also contains many other property for details. Hope this helps. Regards :)

          M Offline
          M Offline
          mike montagne
          wrote on last edited by
          #4

          In other words, the following approach does identify the assembly I need to identify, but I run into a dead end trying to get an IntPtr handle from the "ModuleHandle" struct:

                         Type t = this.GetType( );
                         Assembly a = Assembly.GetAssembly( t ); // SUCCESSFULLY RETURNS THE RIGHT ASSEMBLY, BUT HOW DO WE GET AN IntPtr HANDLE TO THIS?
                         ModuleHandle mh = a.GetModule( "APC" ).ModuleHandle; // CAN WE GET AN IntPtr TO THE HINSTANCE SOMEHOW FROM mh?
          

          Do you know of a way to get the IntPtr value that will return the resources we need to find with Bitmap.FromResource()?

          M 1 Reply Last reply
          0
          • M mike montagne

            In other words, the following approach does identify the assembly I need to identify, but I run into a dead end trying to get an IntPtr handle from the "ModuleHandle" struct:

                           Type t = this.GetType( );
                           Assembly a = Assembly.GetAssembly( t ); // SUCCESSFULLY RETURNS THE RIGHT ASSEMBLY, BUT HOW DO WE GET AN IntPtr HANDLE TO THIS?
                           ModuleHandle mh = a.GetModule( "APC" ).ModuleHandle; // CAN WE GET AN IntPtr TO THE HINSTANCE SOMEHOW FROM mh?
            

            Do you know of a way to get the IntPtr value that will return the resources we need to find with Bitmap.FromResource()?

            M Offline
            M Offline
            Martin 0
            wrote on last edited by
            #5

            Hello, I'm not an expert at all, but I found this article, where it is done by an "Kernel32.dll" method call. http://www.codeproject.com/cs/miscctrl/XPTaskBar.asp[^]

            	\[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)\]
            	public static extern IntPtr LoadLibrary(string lpFileName);
            

            Hope it helps! All the best, Martin

            M 1 Reply Last reply
            0
            • M Martin 0

              Hello, I'm not an expert at all, but I found this article, where it is done by an "Kernel32.dll" method call. http://www.codeproject.com/cs/miscctrl/XPTaskBar.asp[^]

              	\[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)\]
              	public static extern IntPtr LoadLibrary(string lpFileName);
              

              Hope it helps! All the best, Martin

              M Offline
              M Offline
              mike montagne
              wrote on last edited by
              #6

              Thanks, Martin, but the problem here is the approach is not CLS compliant. We need to be able to do this with managed code. It's "as if" Microsoft left out a vital bridge so that, as we are obstructed from a managed solution, we are forced to write Microsoft-dependent approaches.

              M 1 Reply Last reply
              0
              • M mike montagne

                Thanks, Martin, but the problem here is the approach is not CLS compliant. We need to be able to do this with managed code. It's "as if" Microsoft left out a vital bridge so that, as we are obstructed from a managed solution, we are forced to write Microsoft-dependent approaches.

                M Offline
                M Offline
                Martin 0
                wrote on last edited by
                #7

                Ok, I see! P.S.: Have no idea why somebody voted "2" for your statement? Gave you "5" to bring it back in shape! All the best, Martin

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups