在OS X上检查程序集(dll)的版本

问题描述 投票:5回答:5

如何在OS X上检查dll的版本?

dll是用C#创建的,这就是我所知道的。

macos dll mono .net-assembly
5个回答
5
投票

取决于你想要找到什么样的信息...你可以在Xamarin Studio的项目中添加对DLL的引用,然后展开References文件夹并双击DLL ...这将在AssemblyBrowser中打开它并显示当前的AssemblyInfo编译成DLL。

如果您想知道为其构建DLL的体系结构,请在终端窗口中运行它:

file insert_filename_here.dll

如果它是一个x86(或“任何CPU”)DLL,它会说:

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

如果它是一个x64 DLL,它会说:

insert_filename_here.dll: PE32+ executable for MS Windows (DLL) (console) Mono/.Net assembly!

4
投票

一种非常快速和简单的方法是发出cat命令并读取最后几行,例如

$ cat mylibrary.dll


3
投票

您可以编写一些代码来执行此操作。创建包含以下内容的Program.cs

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}");
        }
    }
}

要在mono上找到test.dll的版本:

csc Program.cs
mono Program.exe test.dll

要在.NET Core上找到test.dll的版本,首先要创建包含以下内容的Program.csproj

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

然后运行:

dotnet run test.dll

如果您有.NET Core 2.1,则可以使用.NET Core全局工具dotnet-versioninfo。它可以像这样安装:

dotnet tool install --global dotnet-versioninfo

然后运行:

versioninfo test.dll

1
投票

如果使用Mono Cecil将程序集加载到内存(AssemblyDefinition.ReadAssembly),则可以读取版本属性(AssemblyDefinition.Name.Version)。

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

也可以使用反射,但它需要您将程序集加载到效率不高的appdomain中。

Xamarin Studio内部使用Cecil或反射来查询程序集中的相同信息。


0
投票

如果您不需要以编程方式使用它,可以在TextEdit中打开它(快速查看,然后单击“在TextEdit中打开”按钮)并一直滚动到底部。您应该看到类似以下的内容

<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
© www.soinside.com 2019 - 2024. All rights reserved.