Skip to content

How to get ClrInfo and Dac info using ClrMD

Lets take a look at some basic CLR information which is essential before delving into other kinds of data for troubleshooting. Also keep in mind DAC is extremely important to get data about CLR Runtime.

So here is the code to dump CLR Information and also DAC. Don’t forget to reference Microsoft.Diagnostics.Runtime (Nuget package) for this console App. The code below iterates through all the available CLR runtime.

Code to get CLR Info and details about DAC

using DataTarget dt = DataTarget.LoadDump(args[0]);

Console.WriteLine("\n>>> CLR Info");
Console.WriteLine($"Architecture.: {dt.DataReader.Architecture}");
Console.WriteLine($"Pointer Size.: {dt.DataReader.PointerSize}");
Console.WriteLine($"Display Name.: {dt.DataReader.DisplayName}");

foreach (ClrInfo clr in dt.ClrVersions)
	Console.WriteLine($"Clr Flavor...: {clr.Flavor}");
	Console.WriteLine($"Clr Version..: {clr.Version}");

	// This is the data needed to request the dac from the symbol server:
	DacInfo dacInfo = clr.DacInfo;
	Console.WriteLine("Filesize.....: {0:X}", dacInfo.IndexFileSize);
	Console.WriteLine("Timestamp....: {0:X}", dacInfo.IndexTimeStamp);
	Console.WriteLine("Dac File.....: {0}", dacInfo.PlatformSpecificFileName);

	// If we just happen to have the correct dac file installed on the machine,
	// the "LocalMatchingDac" property will return its location on disk:
	string dacLocation = clr.DacInfo.LocalDacPath;
	if (!string.IsNullOrEmpty(dacLocation))
		Console.WriteLine("Local DAC....: " + dacLocation);

How the output of the above code looks like

>>>> CLR Info
Architecture.: Amd64
Pointer Size.: 8
Display Name.: DbgEng, IDebugClient=1d695b325b8
Clr Flavor...: Core
Clr Version..: 4.700.20.20201
Filesize.....: 56C000
Timestamp....: 5E867108
Dac File.....: mscordaccore_Amd64_Amd64_4.700.20.20201.dll
Local DAC....: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.4\mscordaccore.dll

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: