public static List <AssemblyName> GetAssemblyNames(IList <string> files, out string error) { error = null; if (files == null || files.Count == 0) { return(null); } var names = new List <AssemblyName> (); foreach (var file in files) { if (!File.Exists(file)) { error = GettextCatalog.GetString("User assembly '{0}' is missing. " + "Debugger will now debug all code, not just user code.", file); return(null); } try { var asm = Mono.Cecil.AssemblyFactory.GetAssemblyManifest(file); if (string.IsNullOrEmpty(asm.Name.Name)) { throw new InvalidOperationException("Assembly has no assembly name"); } names.Add(new AssemblyName(asm.Name.FullName)); } catch (Exception ex) { error = GettextCatalog.GetString("Could not get assembly name for user assembly '{0}'. " + "Debugger will now debug all code, not just user code.", file); MDLS.LogError("Error getting assembly name for user assembly '" + file + "'", ex); return(null); } } return(names); }
public static void SetUserAssemblyNames(SoftDebuggerStartInfo dsi, IList <string> files) { if (files == null || files.Count == 0) { return; } var names = new List <AssemblyName> (); foreach (var file in files) { if (!File.Exists(file)) { dsi.LogMessage = GettextCatalog.GetString("User assembly '{0}' is missing. " + "Debugger will now debug all code, not just user code.", file); return; } try { var asm = Mono.Cecil.AssemblyDefinition.ReadAssembly(file); if (string.IsNullOrEmpty(asm.Name.Name)) { throw new InvalidOperationException("Assembly has no assembly name"); } names.Add(new AssemblyName(asm.Name.FullName)); } catch (Exception ex) { dsi.LogMessage = GettextCatalog.GetString("Could not get assembly name for user assembly '{0}'. " + "Debugger will now debug all code, not just user code.", file); MDLS.LogError("Error getting assembly name for user assembly '" + file + "'", ex); return; } } dsi.UserAssemblyNames = names; }
static void HandleUserDataMigration(object sender, ExtensionNodeEventArgs args) { if (args.Change != ExtensionChange.Add) { return; } var node = (UserDataMigrationNode)args.ExtensionNode; if (node.SourceVersion != version) { return; } FilePath source = FilePath.Null; FilePath target = FilePath.Null; try { source = profile.GetLocation(node.Kind).Combine(node.SourcePath); target = PropertyService.Locations.GetLocation(node.Kind).Combine(node.TargetPath); bool sourceIsDirectory = Directory.Exists(source); if (sourceIsDirectory) { if (Directory.Exists(target)) { return; } } else { if (File.Exists(target) || Directory.Exists(target) || !File.Exists(source)) { return; } } LoggingService.LogInfo("Migrating '{0}' to '{1}'", source, target); if (!sourceIsDirectory) { FileService.EnsureDirectoryExists(target.ParentDirectory); } var handler = node.GetHandler(); if (handler != null) { handler.Migrate(source, target); return; } if (sourceIsDirectory) { DirectoryCopy(source, target); } else { File.Copy(source, target); } } catch (Exception ex) { string message = string.Format("{0}: Failed to migrate '{1}' to '{2}'", node.Addin.Id, source.ToString() ?? "", target.ToString() ?? ""); LoggingService.LogError(message, ex); } }