Cannot get assembly's FileVersionInfo .DLL that packed into .XLL add-in file.

85 views
Skip to first unread message

John S

unread,
Dec 22, 2016, 10:52:42 PM12/22/16
to Excel-DNA
Hi Govert,

I want to get assembly's FileVersionInfo .DLL that packed into .XLL add-in file.

I config project assembly as below:
- Assembly version: 2.1.0.1
- Assembly File version: 3.3.0.3

I tried to get Assembly version as below:

Sub TestGetAssemblyInfo()

    Dim myAssemblyName As AssemblyName
    Dim strAssemblyVersion As String

    Dim myAssembly As Assembly
    Dim strAssemblyFileVersion As String
    Dim strXLLFileVersion As String

    Try

        myAssemblyName = New AssemblyName(Assembly.GetExecutingAssembly().FullName)
        strAssemblyVersion = myAssemblyName.Version.ToString()

        myAssembly = Assembly.GetExecutingAssembly
        strAssemblyFileVersion = FileVersionInfo.GetVersionInfo(myAssembly.Location).FileVersion

        strXLLFileVersion = FileVersionInfo.GetVersionInfo("XLL_A.xll").FileVersion

        MsgBox("Assembly Version: " & strAssemblyVersion & vbNewLine & _
               "DLL File Version: " & strAssemblyFileVersion & vbNewLine & _
               "XLL File Version: " & strXLLFileVersion)

    Catch ex As Exception

        MsgBox(ex.Message)

    End Try

End Sub

The result as below:
- Assembly Version: 2.1.0.1
- DLL File Version: 3.3.0.3
- XLL File Version: 0.33.9.1

But I want the XLL File Version is 3.3.0.3
Because after I packed .DLL file to .XLL file add-in, I have only .XLL file.

Please let me know your idea.

Thank for your help,
John.

Govert van Drimmelen

unread,
Dec 23, 2016, 12:23:27 AM12/23/16
to exce...@googlegroups.com
The .xll is not the file you are looking for.
The packed assembly was loaded from bytes, and not as a file from the file system.
See Jon Skeet's answer here for retrieving the AssemblyFileVersion from your assembly: http://stackoverflow.com/questions/8016477/how-can-i-get-the-fileversion-from-an-assembly-that-has-been-loaded-from-bytes

-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

John S

unread,
Dec 26, 2016, 9:48:01 PM12/26/16
to Excel-DNA
Thanks Govert,
The Jon Skeet's solution run OK.
Reply all
Reply to author
Forward
0 new messages