internal InstallationInfo(string path) { Path = path; Installed = File.Exists(InstallationManager.GetDebuggerVisualizerFilePath(path)); if (!Installed) { return; } // Trying to determine the version by loading it into a sandbox domain. try { #if NETFRAMEWORK Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence); AppDomain sandboxDomain = AppDomain.CreateDomain(nameof(InitializerSandbox), evidence, Files.GetExecutingPath(), null, false); try { // initializing by the constructor rather than unwrapping and calling a public method because unwrap may fail if executed from a Visual Studio package #if NET35 Activator.CreateInstance(sandboxDomain, Assembly.GetExecutingAssembly().FullName, typeof(InitializerSandbox).FullName, false, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this, path }, null, null, evidence); #else Activator.CreateInstance(sandboxDomain, Assembly.GetExecutingAssembly().FullName, typeof(InitializerSandbox).FullName, false, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this, path }, null, null); #endif } finally { AppDomain.Unload(sandboxDomain); } #else var context = new SandboxContext(path); try { // note: we use LoadFromStream instead of LoadFromAssemblyPath because that keeps the file locked even after unloading the context using var fs = File.OpenRead(InstallationManager.GetDebuggerVisualizerFilePath(path)); Assembly asm = context.LoadFromStream(fs); Version = asm.GetName().Version; RuntimeVersion = asm.ImageRuntimeVersion; TargetFramework = (Attribute.GetCustomAttribute(asm, typeof(TargetFrameworkAttribute)) as TargetFrameworkAttribute)?.FrameworkName; } catch (Exception e) when(!e.IsCritical()) { Version = null; RuntimeVersion = null; } finally { context.Unload(); } #endif } catch (Exception e) when(!e.IsCritical()) { RuntimeVersion = null; InitializeInfoByFileVersion(path); } }