public static ClrMDSession LoadCrashDump(string dumpPath, string dacFile = null)
        {
            if (s_currentSession != null && s_lastDumpPath == dumpPath)
            {
                TestInvalidComObjectException();
                return(s_currentSession);
            }

            Detach();

            DataTarget target = DataTarget.LoadCrashDump(dumpPath);

            try
            {
                bool really64Bit = IsClrModule64Bit(target);

                if (!really64Bit && target.Architecture == Architecture.Amd64)
                {
                    throw new InvalidOperationException("Invalid dump file. The dump was taken from a process with the wrong architecture. (e.g. Creating a dump of a x86 process from the x64 taskmgr.exe)");
                }

                if (target.Architecture == Architecture.X86 && Environment.Is64BitProcess ||
                    target.Architecture == Architecture.Amd64 && !Environment.Is64BitProcess)
                {
                    throw new InvalidOperationException("Mismatched architecture between this process and the target dump.");
                }

                if (dacFile == null)
                {
                    dacFile = target.ClrVersions[0].TryGetDacLocation();
                }

                if (string.IsNullOrEmpty(dacFile))
                {
                    using (var locator = DacLocator.FromPublicSymbolServer("Symbols"))
                    {
                        dacFile = locator.FindDac(target.ClrVersions[0]);
                    }
                }
            }
            catch
            {
                target.Dispose();
                throw;
            }

            s_lastDumpPath = dumpPath;
            return(new ClrMDSession(target, dacFile));
        }
        public static ClrMDSession LoadCrashDump(string dumpPath, string dacFile = null)
        {
            if (s_currentSession != null && s_lastDumpPath == dumpPath)
            {
                TestInvalidComObjectException();
                return(s_currentSession);
            }

            Detach();

            DataTarget target = DataTarget.LoadCrashDump(dumpPath);

            try
            {
                if (target.Architecture == Architecture.X86 && Environment.Is64BitProcess ||
                    target.Architecture == Architecture.Amd64 && !Environment.Is64BitProcess)
                {
                    throw new InvalidOperationException("Mismatched architecture between this process and the target dump.");
                }

                if (dacFile == null)
                {
                    dacFile = target.ClrVersions[0].TryGetDacLocation();
                }

                if (string.IsNullOrEmpty(dacFile))
                {
                    using (var locator = DacLocator.FromPublicSymbolServer("Symbols"))
                    {
                        dacFile = locator.FindDac(target.ClrVersions[0]);
                    }
                }
            }
            catch
            {
                target.Dispose();
                throw;
            }

            s_lastDumpPath = dumpPath;
            return(new ClrMDSession(target, dacFile));
        }