public void Register(string path) { try { AssemblyName assemblyName = new AssemblyName(); assemblyName.Name = Path.GetFileNameWithoutExtension(path); assemblyName.CodeBase = path; Assembly assembly = Assembly.Load(assemblyName); foreach (Type type in assembly.GetExportedTypes()) { if (type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1) { Addin addin = new Addin(type); addinRegistry.Register(addin); } } } catch (Exception ex) { // NOTE: Since the gui isn't loaded at this point, // the trace output will only show up in Visual Studio Trace.WriteLine("Extension not loaded: " + path); Trace.WriteLine(ex.ToString()); } }
public void Register(string path) { try { AssemblyName assemblyName = new AssemblyName(); assemblyName.Name = Path.GetFileNameWithoutExtension(path); assemblyName.CodeBase = path; Assembly assembly = Assembly.Load(assemblyName); log.Debug("Loaded " + Path.GetFileName(path)); foreach (Type type in assembly.GetExportedTypes()) { if (type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1) { Addin addin = new Addin(type); if (addinRegistry.IsAddinRegistered(addin.Name)) { log.Error("Addin {0} was already registered", addin.Name); } else { addinRegistry.Register(addin); log.Debug("Registered addin: {0}", addin.Name); } } } } catch (Exception ex) { // NOTE: Since the gui isn't loaded at this point, // the trace output will only show up in Visual Studio log.Error("Failed to load" + path, ex); } }