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,436
  • 26
  • 44
  • 46

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
  • 648
  • 1
  • 10
  • 22
0

In PowerShell

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