2

I am looking for a way to look at an assembly in c# and determine if it is a .net core assembly or a framework assembly. In addition, if it is a 64bit or 32bit.

The assembly will not be running.

I am using it to identify the type of worker process I need to create to process the assembly.

ekad
  • 14,056
  • 26
  • 43
  • 45

2 Answers2

1

C# not tested with .net works with .net core... Also checkout System.Runtime.InteropServices.RuntimeInformation

    private static void Main(string[] args)
    {
        Assembly assembly = Assembly.GetExecutingAssembly();
        var framework = Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName;
        Console.WriteLine($"{assembly.GetName().ProcessorArchitecture.ToString()} - {framework}");
        Console.ReadLine();
    }

Check out: https://weblog.west-wind.com/posts/2018/Apr/12/Getting-the-NET-Core-Runtime-Version-in-a-Running-Application

Zulander
  • 562
  • 7
  • 21
0

In PowerShell

[reflection.assemblyname]::GetAssemblyName("") | fl
Travis Primm
  • 139
  • 2
  • 3