locked
File version of my class library RRS feed

  • Question

  • I've looked and found app version... but I am looking for is how to find the file version of my library. when I select the properites of my dll, I want to be able to pass that back to the client app using the dll?
    Wednesday, September 17, 2014 3:57 AM

Answers

  • Hi,

     Here is two public functions you can try in your class. One returns the Assembly Version and the other returns the File Version.

    Add these to your class

    Public Class Class1
    
        Public Function GetAssemblyVersion() As String
            Return (GetType(Class1).Assembly.GetName().Version).ToString 'Use the name of your class in the GetType()
        End Function
    
        Public Function GetFileVersion() As String
            Return FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion
        End Function
    End Class
    

     Then in the form that you added a reference to your class you can call them like this.

    Imports GetVersionTest
    
    Public Class Form1
        Dim gvt As New Class1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            MessageBox.Show(gvt.GetAssemblyVersion)
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            MessageBox.Show(gvt.GetFileVersion)
        End Sub
    End Class
    


    If you say it can`t be done then i`ll try it

    • Marked as answer by LandLord323 Thursday, September 18, 2014 4:22 AM
    Wednesday, September 17, 2014 7:45 PM

All replies

  • .

    FileVersionInfo.FileVersion Property

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            RichTextBox1.Clear()
            Dim FVI As FileVersionInfo = FileVersionInfo.GetVersionInfo("C:\Users\John\Documents\Visual Studio 2012\MyDll\MyDll\bin\Debug\MyDll.Dll")
            RichTextBox1.AppendText(FVI.FileVersion)
    End Sub


    La vida loca

    Wednesday, September 17, 2014 4:46 AM
  • Wednesday, September 17, 2014 4:50 AM
  • I've looked at that.. not quite what I am looking for... I am wanting a function in my library, to return the version of the dll to the client, not the client version.

    Wednesday, September 17, 2014 1:50 PM
  • I've looked and found app version... but I am looking for is how to find the file version of my library. when I select the properites of my dll, I want to be able to pass that back to the client app using the dll?

    I think you'll find this article interesting. It's pretty short.

    Still lost in code, just at a little higher level.

    :-)

    Wednesday, September 17, 2014 5:49 PM
  • Hi,

     Here is two public functions you can try in your class. One returns the Assembly Version and the other returns the File Version.

    Add these to your class

    Public Class Class1
    
        Public Function GetAssemblyVersion() As String
            Return (GetType(Class1).Assembly.GetName().Version).ToString 'Use the name of your class in the GetType()
        End Function
    
        Public Function GetFileVersion() As String
            Return FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion
        End Function
    End Class
    

     Then in the form that you added a reference to your class you can call them like this.

    Imports GetVersionTest
    
    Public Class Form1
        Dim gvt As New Class1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            MessageBox.Show(gvt.GetAssemblyVersion)
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            MessageBox.Show(gvt.GetFileVersion)
        End Sub
    End Class
    


    If you say it can`t be done then i`ll try it

    • Marked as answer by LandLord323 Thursday, September 18, 2014 4:22 AM
    Wednesday, September 17, 2014 7:45 PM