16

How do I check the version of a dll on OS X?

The dll is managed, created in C#, that's all I know.

Roberto
  • 11,557
  • 16
  • 54
  • 68

10 Answers10

13

A very quick and simple way is to issue the cat command and read the last few lines e.g.

$ cat mylibrary.dll

John Newcombe
  • 364
  • 2
  • 7
  • 7
    Or to just see the end of the file `$ tail -c 1740 Newtonsoft.Json.dll` – David Clarke Aug 06 '17 at 21:59
  • This relies on having a terminal that follows ANSI standards and silently ignores NUL bytes. That's common, but not universal. And failing to use the `tail` suggestion in the comment above greatly increases the chances of the binary data preceding corrupting terminal settings. – Charles Duffy Sep 04 '22 at 17:52
7

Depends what kind of information you want to find… you can add a reference to the DLL in a project in Xamarin Studio and then expand the References folder & double-click on the DLL… this will open it in AssemblyBrowser and display the AssemblyInfo that was compiled into the DLL.

Viewing AssemblyInfo in Xamarin Studio

If you want to know what architecture the DLL was built for, run this in a Terminal window:

file insert_filename_here.dll

If it's a x86 (or "Any CPU") DLL, it will say:

insert_filename_here.dll: PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit Mono/.Net assembly

If it's an x64 DLL, it will say:

insert_filename_here.dll: PE32+ executable for MS Windows (DLL) (console) Mono/.Net assembly!
Matt Welch
  • 670
  • 4
  • 11
7

You can write a bit of code to do it. Create Program.cs containing:

using System;
using System.Diagnostics;

namespace FileVersionInfoExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var fileName = args[0];
            var fvi = FileVersionInfo.GetVersionInfo(fileName);
            Console.WriteLine($"FileVersion:\t{fvi.FileVersion}");
            Console.WriteLine($"ProductVersion:\t{fvi.ProductVersion}");
        }
    }
}

To find the version of test.dll on mono:

csc Program.cs
mono Program.exe test.dll

To find the version of test.dll on .NET Core, first create Program.csproj containing:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
</Project>

then run:

dotnet run test.dll

If you have .NET Core 2.1, there is a .NET Core Global Tool, dotnet-versioninfo that you can use. It can be installed like this:

dotnet tool install --global dotnet-versioninfo

Then run:

versioninfo test.dll
7

Using monodis or ikdasm it can be done like this:

monodis --assembly filename.dll
Nuno Luis
  • 71
  • 2
  • 4
1

If you use Mono Cecil to load the assembly into memory (AssemblyDefinition.ReadAssembly), you can read the version attribute (AssemblyDefinition.Name.Version).

https://github.com/jbevain/cecil/tree/master/Mono.Cecil

Reflection can also be used, but it requires you to load the assembly into an appdomain which is not efficient.

Xamarin Studio internally uses Cecil or reflection to query the same information from the assembly.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
1

A long time ago I created a dotnet tool called DllProps for that.

$ dotnet tool install --global DllProps.Tool
$ dll-props your.dll
Company: Dll-Company
Copyright: Copyright (c) 2021
FileVersion: 9.4.2.0
ProductVersion: 9.4.2.123456
Description: Your
baruchiro
  • 5,088
  • 5
  • 44
  • 66
1

Go to powershell on mac.

(Get-Item "./path/to/your/file.dll").VersionInfo.ProductVersion

GBute
  • 11
  • 4
0

If you don't need it programmatically you can open it in TextEdit (Quick Look, then click the Open in TextEdit button) and scroll all the way to the bottom. You should see something like the following

<MonoTouch,Version=v1.0TFrameworkDisplayName MonoTouchXamarin.MobileXamarin Inc.(#Copyright ¬© 2011-2013 Xamarin Inc.0.7.1.0TWrapNonExceptionThrowsÄû.ÄÑSystem.Security.Permissions.SecurityPermissionAttribute, mscorlib, Version=2.0.5.0, Culture=neutral, 
PublicKeyToken=7cec85d7bea7798eTSkipVerificationúŸæŸ ∞Ÿ_CorDllMainmscoree.dllˇ% Ä0ÄHX‡@@4VS_VERSION_INFOΩÔ˛?DVarFileInfo$Translation∞†StringFileInfo|000004b0<CompanyNameXamarin Inc.HFileDescriptionXamarin
.Mobile0FileVersion0.7.1.0HInternalNameXamarin.Mobile.dlll#LegalCopyrightCopyright © 2011-2013 Xamarin Inc.POriginalFilenameXamarin.Mobile.dll@ProductNameXamarin.Mobile4ProductVersion0.7.1.08Assembly Version0.7.1.0––9
Nate Cook
  • 8,395
  • 5
  • 46
  • 37
0

I've created a macOS command line utility called win_file_version to access the version number of a Windows EXE or DLL. You can request either the numeric file version or product version, or the file version or product version string from the STRING FILE INFO section.

A description is available in the README, and the first release is available in the release section of the GitHub repository.

Enjoy.

Mark Coniglio
  • 351
  • 1
  • 10
0

You can use utility named strings, version starts from letter 'v', so we can grep such lines:

root@ad5596660846:/app# strings System.Threading.dll  | grep '^v'
v4.0.30319
value__
value
vv:S
orlovw
  • 405
  • 3
  • 11