public static void TraceXamlLoaderError([NotNull] this ExportProvider exportProvider, [CanBeNull] Exception ex) { var exception = ex?.Message; if (exception != null) { exportProvider.TraceError(exception); } var path = Path.GetDirectoryName(typeof(ITracer).Assembly.Location); Contract.Assume(!string.IsNullOrEmpty(path)); var assemblyFileNames = Directory.EnumerateFiles(path, @"*.dll") .ToArray(); var assemblyNames = new HashSet <string>(assemblyFileNames.Select(Path.GetFileNameWithoutExtension)); var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); var assemblies = loadedAssemblies .Where(a => assemblyNames.Contains(a.GetName().Name)) .ToArray(); var messages = assemblies .Select(assembly => string.Format(CultureInfo.CurrentCulture, "Assembly '{0}' loaded from {1}", assembly.FullName, assembly.CodeBase)) .OrderBy(text => text, StringComparer.OrdinalIgnoreCase) .ToArray(); foreach (var message in messages) { exportProvider.WriteLine(message); } var assembliesByName = assemblies .GroupBy(a => a.FullName) .Where(g => g.Count() > 1) .Select(g => g.Key) .ToArray(); if (assembliesByName.Any()) { exportProvider.WriteLine("Duplicate assemblies found: " + string.Join(", ", assembliesByName)); } exportProvider.WriteLine("Please read https://github.com/tom-englert/ResXResourceManager/wiki/Fixing-errors before creating an issue."); }
public VsixShellView([NotNull] ExportProvider exportProvider, [NotNull] ThemeManager themeManager, VsixShellViewModel viewModel) { Contract.Requires(exportProvider != null); Contract.Requires(themeManager != null); _themeManager = themeManager; try { this.SetExportProvider(exportProvider); InitializeComponent(); DataContext = viewModel; Resources.MergedDictionaries.Add(DataTemplateManager.CreateDynamicDataTemplates(exportProvider)); } catch (Exception ex) { exportProvider.TraceError(ex.ToString()); var path = Path.GetDirectoryName(GetType().Assembly.Location); Contract.Assume(!string.IsNullOrEmpty(path)); var assemblyFileNames = Directory.EnumerateFiles(path, @"*.dll") .Where(file => !"DocumentFormat.OpenXml.dll".Equals(Path.GetFileName(file), StringComparison.OrdinalIgnoreCase)) .ToArray(); var assemblyNames = new HashSet <string>(assemblyFileNames.Select(Path.GetFileNameWithoutExtension)); var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); var messages = loadedAssemblies .Where(a => assemblyNames.Contains(a.GetName().Name)) .Select(assembly => string.Format(CultureInfo.CurrentCulture, "Assembly '{0}' loaded from {1}", assembly.FullName, assembly.CodeBase)) .OrderBy(text => text, StringComparer.OrdinalIgnoreCase) .ToArray(); foreach (var message in messages) { exportProvider.WriteLine(message); } } }