File md10-to-20080904.diff of Package monodevelop

Index: src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployFileListWidget.cs
===================================================================
--- src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployFileListWidget.cs	(revision 97933)
+++ src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployFileListWidget.cs	(revision 112335)
@@ -103,10 +103,10 @@
 			return "";
 		}		
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
 			context.Dispose ();
-			base.Dispose ();
+			base.OnDestroyed ();
 		}
 
 		void OnToggled (object sender, Gtk.ToggledArgs args)
Index: src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDirectoryInfoEditor.cs
===================================================================
--- src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDirectoryInfoEditor.cs	(revision 97933)
+++ src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDirectoryInfoEditor.cs	(revision 112335)
@@ -53,11 +53,6 @@
 			}
 		}
 
-		public override void Dispose ()
-		{
-			base.Dispose ();
-		}
-
 		public object Value {
 			get {
 				if (combo.Active != -1)
Index: src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/TextEditor.cs
===================================================================
--- src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/TextEditor.cs	(revision 97933)
+++ src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/TextEditor.cs	(revision 112335)
@@ -105,9 +105,14 @@
 			}
 		}
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
-			base.Dispose ();
+			base.OnDestroyed ();
+			((IDisposable)this).Dispose ();
+		}
+
+		void IDisposable.Dispose ()
+		{
 			if (!disposed && initialText != entry.Text) {
 				TextChanged (null, null);
 			}
Index: src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/EnumerationEditorCell.cs
===================================================================
--- src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/EnumerationEditorCell.cs	(revision 97933)
+++ src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/EnumerationEditorCell.cs	(revision 112335)
@@ -112,11 +112,19 @@
 				combo.AppendText (str);
 			}
 		}
+		
+		protected override void OnDestroyed ()
+		{
+			base.OnDestroyed ();
+			((IDisposable)this).Dispose ();
+		}
 
-		public override void Dispose ()
+		void IDisposable.Dispose ()
 		{
-			tips.Destroy ();
-			base.Dispose ();
+			if (tips != null) {
+				tips.Destroy ();
+				tips = null;
+			}
 		}
 
 		public object Value {
Index: src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/FlagsEditorCell.cs
===================================================================
--- src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/FlagsEditorCell.cs	(revision 97933)
+++ src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.PropertyGrid.Editors/FlagsEditorCell.cs	(revision 112335)
@@ -128,12 +128,20 @@
 			}
 		}
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
-			tips.Destroy ();
-			base.Dispose ();
+			base.OnDestroyed ();
+			((IDisposable)this).Dispose ();
 		}
 
+		void IDisposable.Dispose ()
+		{
+			if (tips != null) {
+				tips.Destroy ();
+				tips = null;
+			}
+		}
+
 		public object Value {
 			get {
 				return Enum.ToObject (propType, UIntValue);
Index: src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs	(revision 112335)
@@ -76,7 +76,7 @@
 			return GtkCoreService.SupportsGtkDesigner (project);
 		}
 		
-		public override void AddToProject (Project project, string language, string directory, string name)
+		public override bool AddToProject (Project project, string language, string directory, string name)
 		{
 			GtkDesignInfo info = GtkCoreService.GetGtkInfo (project);
 			if (info == null)
@@ -112,7 +112,7 @@
 				
 				if (!w.IsWindow)
 					info.AddExportedWidget (fullName);
-				return;
+				return true;
 			}
 			
 			widgetElem = steticTemplate ["action-group"];
@@ -125,7 +125,7 @@
 				
 				gproject.SteticProject.AddNewActionGroup (doc.DocumentElement);
 				gproject.Save (false);
-				return;
+				return true;
 			}
 			
 			throw new InvalidOperationException ("<widget> or <action-group> element not found in widget template.");
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupDesigner.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupDesigner.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupDesigner.cs	(revision 112335)
@@ -178,6 +178,7 @@
 			System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
 			if (editSession != null)
 				editSession.Dispose ();
+			editSession = null;
 			base.Dispose ();
 		}
 		
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/LibraryCache.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/LibraryCache.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/LibraryCache.cs	(revision 112335)
@@ -1,138 +1,270 @@
+// LibraryCache.cs : Assembly file caching class
+//
+// Author: Mike Kestner  <mkestner@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+
 using System;
 using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.IO;
 using System.Xml;
+using System.Xml.Serialization;
+using ENV = System.Environment;
+using Mono.Cecil;
 
-namespace Stetic
-{
-	static class LibraryCache
-	{
-		static string cachePath;
-		static XmlDocument indexDoc;
-		
-		static LibraryCache ()
+namespace Stetic {
+
+	public class LibraryCache {
+
+		public class LibraryInfo {
+
+			public LibraryInfo () {}
+
+			string file;
+			Guid guid;
+			bool has_widgets;
+			DateTime timestamp;
+
+			string CacheDirectory {
+				get { 
+					string path = Path.Combine (dir, Guid.ToString ()); 
+					if (!Directory.Exists (path))
+						Directory.CreateDirectory (path);
+					return path;
+				}
+			}
+
+			[XmlAttribute]
+			public string File {
+				get { return file; }
+				set { file = value; }
+			}
+
+			[XmlAttribute]
+			public Guid Guid {
+				get { return guid; }
+				set { 
+					string path = Path.Combine (dir, guid.ToString ());
+					if (Directory.Exists (path))
+						Directory.Delete (path, true);
+					guid = value; 
+				}
+			}
+
+			public string GuiPath {
+				get { return Path.Combine (CacheDirectory, "steticGui"); }
+			}
+
+			[XmlAttribute]
+			public bool HasWidgets {
+				get { return has_widgets; }
+				set { has_widgets = value; }
+			}
+
+			public string ObjectsPath {
+				get { return Path.Combine (CacheDirectory, "objects"); }
+			}
+
+			[XmlAttribute]
+			public DateTime Timestamp {
+				get { return timestamp; }
+				set { timestamp = value; }
+			}
+		}
+
+		static string dir = Path.Combine (Path.Combine (ENV.GetFolderPath (ENV.SpecialFolder.ApplicationData), "stetic"), "library-cache");
+
+		public class LibraryInfoCollection : IEnumerable {
+
+			Dictionary<string, LibraryInfo> libs = new Dictionary<string, LibraryInfo> ();
+
+			public LibraryInfo this [string path] {
+				get {
+					path = Path.GetFullPath (path);
+					if (libs.ContainsKey (path))
+						return libs [path];
+					return null;
+				}
+			}
+
+			public void Add (object obj)
+			{
+				Add (obj as LibraryInfo);
+			}
+				
+			public void Add (LibraryInfo info)
+			{
+				libs [info.File] = info;
+			}
+
+			public IEnumerator GetEnumerator ()
+			{
+				return libs.Values.GetEnumerator ();
+			}
+
+			public void Remove (string file)
+			{
+				file = Path.GetFullPath (file);
+				libs.Remove (file);
+			}
+		}
+
+		[XmlArray]
+		[XmlArrayItem (ElementName="LibraryInfo", Type=typeof(LibraryInfo))]
+		public LibraryInfoCollection Members = new LibraryInfoCollection ();
+
+		public LibraryCache () {}
+
+		public LibraryInfo this [string file] {
+			get {
+				file = Path.GetFullPath (file);
+				if (IsCurrent (file))
+					return Members [file];
+
+				RefreshFile (file);
+				return Members [file];
+			}
+		}
+
+		public bool IsCurrent (string file)
 		{
-			cachePath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config");
-			cachePath = Path.Combine (cachePath, "stetic");
-			cachePath = Path.Combine (cachePath, "desc-cache");
+			file = Path.GetFullPath (file);
+			LibraryInfo info = Members [file];
+			return info != null && info.Timestamp == File.GetLastWriteTime (file).ToUniversalTime ();
 		}
-		
-		static XmlDocument GetIndex ()
+
+		AssemblyResolver resolver = new AssemblyResolver ();
+
+		EmbeddedResource GetResource (AssemblyDefinition asm, string name)
 		{
-			if (indexDoc != null)
-				return indexDoc;
-			
-			string index = Path.Combine (cachePath, "index.xml");
-			if (!File.Exists (index))
-				return null;
-			
-			try {
-				XmlDocument doc = new XmlDocument ();
-				doc.Load (index);
-				return doc;
-			} catch {
-				return null;
+			foreach (Resource res in asm.MainModule.Resources) {
+				EmbeddedResource eres = res as EmbeddedResource;
+				if (eres != null && eres.Name == name)
+					return eres;
 			}
+			return null;
 		}
-		
-		static void SaveIndex (XmlDocument doc)
+ 
+		bool HasGtkReference (AssemblyDefinition assm, StringCollection visited)
 		{
-			if (!Directory.Exists (cachePath))
-				Directory.CreateDirectory (cachePath);
-			
-			// Purge the file list
-			
-			ArrayList todel = new ArrayList ();
-			foreach (XmlElement elem in doc.DocumentElement.SelectNodes ("lib")) {
-				string file = elem.GetAttribute ("file");
-				if (!File.Exists (file)) {
-					todel.Add (elem);
-					string path = elem.GetAttribute ("cached");
-					foreach (string cf in Directory.GetFiles (cachePath, path + "*")) {
-						try {
-							File.Delete (cf);
-						} catch (Exception ex) {
-							// Ignore exception
-							Console.WriteLine (ex);
+			visited.Add (assm.Name.Name);
+
+			foreach (AssemblyNameReference nameRef in assm.MainModule.AssemblyReferences) {
+				if (visited.Contains (nameRef.Name))
+					continue;
+				else if (nameRef.Name == "gtk-sharp" || HasGtkReference (resolver.Resolve (nameRef), visited))
+					return true;
+			}
+
+			return false;
+		}
+
+		bool CheckForWidgets (string path)
+		{
+			try {
+				AssemblyDefinition adef = AssemblyFactory.GetAssembly (path);
+				if (GetResource (adef, "objects.xml") != null)
+					return true;
+				
+				if (adef.Name.Name == "gtk-sharp")
+					return false;  // Gtk is special-cased, so ignore it.
+
+				if (!HasGtkReference (adef, new StringCollection ()))
+					return false;
+
+				foreach (TypeDefinition type in adef.MainModule.Types) {
+					TypeReference tref = type.BaseType;
+					while (tref != null) {
+						if (tref.FullName == "Gtk.Window") {
+							break;
+						} else if (tref.FullName == "Gtk.Widget") {
+							return true;
 						}
+						tref = resolver.Resolve (tref).BaseType;
 					}
 				}
+			} catch {
 			}
-			
-			foreach (XmlElement elem in todel)
-				doc.DocumentElement.RemoveChild (elem);
-			
-			string index = Path.Combine (cachePath, "index.xml");
-			doc.Save (index);
-			indexDoc = doc;
+			return false;
 		}
 		
-		public static string GetCachedFilePath (string assemblyPath)
+		void RefreshFile (string assembly)
 		{
-			assemblyPath = Path.GetFullPath (assemblyPath);
-			
-			XmlDocument doc = GetIndex ();
-			if (doc == null)
-				return null;
-				
-			try {
-				XmlElement elem = (XmlElement) doc.SelectSingleNode ("index/lib[@file='" + assemblyPath + "']");
-				if (elem == null)
-					return null;
-				
-				DateTime ts = XmlConvert.ToDateTime (elem.GetAttribute ("timestamp"), XmlDateTimeSerializationMode.Local);
-				DateTime lastWrite = File.GetLastWriteTime (assemblyPath);
-				if (ts != lastWrite)
-					return null;
-				
-				return Path.Combine (cachePath, elem.GetAttribute ("cached"));
+			assembly = Path.GetFullPath (assembly);
+			LibraryInfo info = Members [assembly];
+			if (info == null) {
+				info = new LibraryInfo ();
+				info.File = assembly;
+				Members.Add (info);
 			}
-			catch (Exception ex) {
-				Console.WriteLine (ex);
-				return null;
+			info.Timestamp = File.GetLastWriteTime (assembly).ToUniversalTime ();
+			info.Guid = Guid.NewGuid ();
+			info.HasWidgets = CheckForWidgets (assembly);
+			Save ();
+		}
+
+		void Save ()
+		{
+			if (!Directory.Exists (dir))
+				Directory.CreateDirectory (dir);
+
+			// remove any dead assemblies from the cache
+			StringCollection zombies = new StringCollection ();
+			foreach (LibraryInfo info in Members) {
+				if (File.Exists (info.File))
+					continue;
+				zombies.Add (info.File);
+				string zombie_dir = Path.Combine (dir, info.Guid.ToString ());
+				if (Directory.Exists (zombie_dir))
+					Directory.Delete (Path.Combine (dir, info.Guid.ToString ()), true);
 			}
+			
+			foreach (string file in zombies)
+				Members.Remove (file);
+			
+			XmlSerializer serializer = new XmlSerializer (typeof (LibraryCache));
+			using (FileStream fs = File.Create (Path.Combine (dir, "index.xml")))
+				serializer.Serialize (fs, this);
 		}
 		
-		public static string UpdateCachedFile (string assemblyPath)
+		public static LibraryCache Load ()
 		{
-			assemblyPath = Path.GetFullPath (assemblyPath);
-			
-			XmlDocument doc = GetIndex ();
-			if (doc == null) {
-				doc = new XmlDocument ();
-				doc.AppendChild (doc.CreateElement ("index"));
-			}
-			
-			try {
-				XmlElement elem = (XmlElement) doc.DocumentElement.SelectSingleNode ("lib[@file='" + assemblyPath + "']");
-				if (elem == null) {
-					elem = doc.CreateElement ("lib");
-					elem.SetAttribute ("file", assemblyPath);
-					doc.DocumentElement.AppendChild (elem);
+			string index_path = Path.Combine (dir, "index.xml");
+			if (File.Exists (index_path)) {
+				try {
+					LibraryCache result;
+					XmlSerializer serializer = new XmlSerializer (typeof (LibraryCache));
+					using (XmlTextReader rdr = new XmlTextReader (index_path))
+						result = (LibraryCache) serializer.Deserialize (rdr);
+					return result;
+				} catch (Exception e) {
+					Console.WriteLine ("Cache index serialization failed " + e);
 				}
-				
-				DateTime lastWrite = File.GetLastWriteTime (assemblyPath);
-				elem.SetAttribute ("timestamp", XmlConvert.ToString (lastWrite, XmlDateTimeSerializationMode.Local));
-				
-				string s = doc.DocumentElement.GetAttribute ("cindex");
-				if (s.Length == 0) s = "0";
-				else s = (int.Parse (s) + 1).ToString ();
-				doc.DocumentElement.SetAttribute ("cindex", s);
-				
-				string cached = elem.GetAttribute ("cached");
-				if (cached.Length == 0) {
-					cached = Path.GetFileNameWithoutExtension (assemblyPath) + "_" + s;
-					elem.SetAttribute ("cached", cached);
-				}
-				
-				SaveIndex (doc);
-				return Path.Combine (cachePath, cached);
 			}
-			catch (Exception ex) {
-				Console.WriteLine (ex);
-				return null;
-			}
+
+			return new LibraryCache ();
 		}
 	}
 }
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/AssemblyResolver.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/AssemblyResolver.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/AssemblyResolver.cs	(revision 112335)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// (C) 2005 Jb Evain
+// (C) 2007 Novell, Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,31 +30,162 @@
 // Keep in synch as much as possible.
 
 using System;
+using System.Collections;
 using System.Collections.Specialized;
 using System.IO;
-using SR = System.Reflection;
 using System.Text;
 using Mono.Cecil;
 
-namespace Stetic
-{
-	internal class AssemblyResolver
-	{
-		public virtual string Resolve (string fullName)
+namespace Stetic {
+
+	internal class AssemblyResolver : BaseAssemblyResolver {
+
+		Hashtable _assemblies;
+
+		public IDictionary AssemblyCache {
+			get { return _assemblies; }
+		}
+
+		public AssemblyResolver ()
 		{
-			return Resolve (fullName, null);
+			_assemblies = new Hashtable ();
 		}
-		
-		public virtual string Resolve (AssemblyNameReference name)
+
+		public override AssemblyDefinition Resolve (AssemblyNameReference name)
 		{
-			return Resolve (name, null);
+			AssemblyDefinition asm = (AssemblyDefinition) _assemblies [name.Name];
+			if (asm == null) {
+				asm = base.Resolve (name);
+				asm.Resolver = this;
+				_assemblies [name.Name] = asm;
+			}
+
+			return asm;
 		}
-		
-		public string Resolve (string fullName, StringCollection basePaths)
+
+		public TypeDefinition Resolve (TypeReference type)
 		{
-			return Resolve (AssemblyNameReference.Parse (fullName), basePaths);
+			if (type is TypeDefinition)
+				return (TypeDefinition) type;
+
+			AssemblyNameReference reference = type.Scope as AssemblyNameReference;
+			if (reference != null) {
+				AssemblyDefinition assembly = Resolve (reference);
+				return assembly.MainModule.Types [type.FullName];
+			}
+
+			ModuleDefinition module = type.Scope as ModuleDefinition;
+			if (module != null)
+				return module.Types [type.FullName];
+
+			throw new NotImplementedException ();
 		}
 
+		public FieldDefinition Resolve (FieldReference field)
+		{
+			TypeDefinition type = Resolve (field.DeclaringType);
+			return GetField (type.Fields, field);
+		}
+
+		static FieldDefinition GetField (ICollection collection, FieldReference reference)
+		{
+			foreach (FieldDefinition field in collection) {
+				if (field.Name != reference.Name)
+					continue;
+
+				if (!AreSame (field.FieldType, reference.FieldType))
+					continue;
+
+				return field;
+			}
+
+			return null;
+		}
+
+		public MethodDefinition Resolve (MethodReference method)
+		{
+			TypeDefinition type = Resolve (method.DeclaringType);
+			if (method.Name == MethodDefinition.Cctor || method.Name == MethodDefinition.Ctor)
+				return GetMethod (type.Constructors, method);
+			else
+				return GetMethod (type, method);
+		}
+
+		MethodDefinition GetMethod (TypeDefinition type, MethodReference reference)
+		{
+			while (type != null) {
+				MethodDefinition method = GetMethod (type.Methods, reference);
+				if (method == null)
+					type = Resolve (type.BaseType);
+				else
+					return method;
+			}
+
+			return null;
+		}
+
+		static MethodDefinition GetMethod (ICollection collection, MethodReference reference)
+		{
+			foreach (MethodDefinition meth in collection) {
+				if (meth.Name != reference.Name)
+					continue;
+
+				if (!AreSame (meth.ReturnType.ReturnType, reference.ReturnType.ReturnType))
+					continue;
+
+				if (!AreSame (meth.Parameters, reference.Parameters))
+					continue;
+
+				return meth;
+			}
+
+			return null;
+		}
+
+		static bool AreSame (ParameterDefinitionCollection a, ParameterDefinitionCollection b)
+		{
+			if (a.Count != b.Count)
+				return false;
+
+			if (a.Count == 0)
+				return true;
+
+			for (int i = 0; i < a.Count; i++)
+				if (!AreSame (a [i].ParameterType, b [i].ParameterType))
+					return false;
+
+			return true;
+		}
+
+		static bool AreSame (TypeReference a, TypeReference b)
+		{
+			while (a is TypeSpecification || b is TypeSpecification) {
+				if (a.GetType () != b.GetType ())
+					return false;
+
+				a = ((TypeSpecification) a).ElementType;
+				b = ((TypeSpecification) b).ElementType;
+			}
+
+			if (a is GenericParameter || b is GenericParameter) {
+				if (a.GetType() != b.GetType())
+					return false;
+
+				GenericParameter pa = (GenericParameter) a;
+				GenericParameter pb = (GenericParameter) b;
+
+				return pa.Position == pb.Position;
+			}
+
+			return a.FullName == b.FullName;
+		}
+
+		public void CacheAssembly (AssemblyDefinition assembly)
+		{
+			_assemblies [assembly.Name.FullName] = assembly;
+			assembly.Resolver = this;
+		}
+
 		public string Resolve (AssemblyNameReference name, StringCollection basePaths)
 		{
 			string [] exts = new string [] { ".dll", ".exe" };
@@ -81,8 +212,7 @@
 
 		string GetCorlib (AssemblyNameReference reference)
 		{
-			SR.AssemblyName corlib = typeof (object).Assembly.GetName ();
-			if (corlib.Version == reference.Version)
+			if (typeof (object).Assembly.GetName ().Version == reference.Version)
 				return typeof (object).Assembly.Location;
 
 			string path = Directory.GetParent (
@@ -111,11 +241,6 @@
 			return Path.Combine (path, "mscorlib.dll");
 		}
 
-		public static bool OnMono ()
-		{
-			return typeof (object).Assembly.GetType ("System.MonoType", false) != null;
-		}
-
 		static string GetAssemblyInGac (AssemblyNameReference reference)
 		{
 			if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/SignalsEditor.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/SignalsEditor.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/SignalsEditor.cs	(revision 112335)
@@ -40,9 +40,16 @@
 			return session.Editor;
 		}
 		
+		bool disposed = false;
+
 		public override void Dispose ()
 		{
-			session.Dispose ();
+			if (disposed)
+				return;
+			disposed = true;
+
+			if (session != null)
+				session.Dispose ();
 			frontend.disposed = true;
 			System.Runtime.Remoting.RemotingServices.Disconnect (frontend);
 			base.Dispose ();
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupToolbar.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupToolbar.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupToolbar.cs	(revision 112335)
@@ -89,7 +89,11 @@
 		
 		public override void Dispose ()
 		{
+			if (combo == null)
+				return;
+
 			combo.Changed -= OnActiveChanged;
+			combo = null;
 			if (addButton != null) {
 				addButton.Clicked -= OnAddGroup;
 				removeButton.Clicked -= OnRemoveGroup;
@@ -159,7 +163,7 @@
 		
 		void Refresh ()
 		{
-			if (singleGroupMode)
+			if (singleGroupMode || combo == null)
 				return;
 
 			while (combo.Model.IterNChildren () > 0)
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupEditSession.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupEditSession.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ActionGroupEditSession.cs	(revision 112335)
@@ -60,6 +60,7 @@
 			designer = UserInterface.CreateActionGroupDesigner (project, groupToolbar);
 			designer.Editor.GroupModified += OnModified;
 			designer.Toolbar.AllowActionBinding = allowActionBinding;
+			designer.Destroyed += delegate { designer = null; Dispose (); };
 		}
 		
 		public Wrapper.ActionGroup EditedActionGroup {
@@ -276,10 +277,10 @@
 		
 		public void Dispose ()
 		{
-			if (designer != null)
+			if (designer != null) {
 				designer.Editor.GroupModified -= OnModified;
-			if (!designerRequested) {
-				designer.Destroy ();
+				if (!designerRequested)
+					designer.Destroy ();
 			}
 			
 			project.ProjectReloaded -= OnProjectReloaded;
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/WidgetActionBar.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/WidgetActionBar.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/WidgetActionBar.cs	(revision 112335)
@@ -19,6 +19,7 @@
 		Hashtable sensitives, invisibles;
 		ArrayList toggles;
 		Gtk.Tooltips tips = new Gtk.Tooltips ();
+		bool disposed;
 		bool updating;
 		bool allowBinding;
 		WidgetDesignerFrontend frontend;
@@ -48,6 +49,11 @@
 		
 		public override void Dispose ()
 		{
+			if (disposed)
+				return;
+			disposed = true;
+			combo.Destroy ();
+			combo = null;
 			RootWidget = null;
 			Clear ();
 			base.Dispose ();
@@ -67,7 +73,8 @@
 				}
 				
 				rootWidget = value;
-				combo.RootWidget = rootWidget;
+				if (combo != null)
+					combo.RootWidget = rootWidget;
 				
 				if (rootWidget != null) {
 					project = (Stetic.ProjectBackend) rootWidget.Project;
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/CecilWidgetLibrary.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/CecilWidgetLibrary.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/CecilWidgetLibrary.cs	(revision 112335)
@@ -11,6 +11,8 @@
 {
 	internal class CecilWidgetLibrary: WidgetLibrary
 	{
+		static LibraryCache cache = LibraryCache.Load ();
+
 		AssemblyDefinition assembly;
 		DateTime timestamp;
 		string name;
@@ -48,16 +50,16 @@
 		
 		void ReadCachedDescription (string assemblyPath)
 		{
-			string path = LibraryCache.GetCachedFilePath (assemblyPath);
-			if (path == null)
+			if (!cache.IsCurrent (assemblyPath))
 				return;
-			
-			if (!File.Exists (path + ".objects"))
+
+			LibraryCache.LibraryInfo info = cache [assemblyPath];
+			if (!File.Exists (info.ObjectsPath))
 				return;
 			
 			try {
 				objects = new XmlDocument ();
-				objects.Load (path + ".objects");
+				objects.Load (info.ObjectsPath);
 			}
 			catch (Exception ex) {
 				Console.WriteLine (ex);
@@ -65,10 +67,10 @@
 				return;
 			}
 			
-			if (File.Exists (path + ".steticGui")) {
+			if (File.Exists (info.GuiPath)) {
 				try {
 					steticGui = new XmlDocument ();
-					steticGui.Load (path + ".steticGui");
+					steticGui.Load (info.GuiPath);
 				}
 				catch (Exception ex) {
 					Console.WriteLine (ex);
@@ -80,19 +82,14 @@
 		
 		void StoreCachedDescription ()
 		{
-			string path = LibraryCache.UpdateCachedFile (fileName);
-			if (path == null)
-				return;
+			LibraryCache.LibraryInfo info = cache [fileName];
 			
 			try {
-				string objfile = path + ".objects";
-				string guifile = path + ".steticGui";
-				
-				objects.Save (objfile);
+				objects.Save (info.ObjectsPath);
 				if (steticGui != null)
-					steticGui.Save (guifile);
-				else if (File.Exists (guifile))
-					File.Delete (guifile);
+					steticGui.Save (info.GuiPath);
+				else if (File.Exists (info.GuiPath))
+					File.Delete (info.GuiPath);
 			}
 			catch (Exception ex) {
 				Console.WriteLine (ex);
@@ -362,18 +359,7 @@
 		
 		public static bool IsWidgetLibrary (string path)
 		{
-			try {
-				AssemblyDefinition adef = AssemblyFactory.GetAssembly (path);
-				
-				foreach (Resource res in adef.MainModule.Resources) {
-					EmbeddedResource eres = res as EmbeddedResource;
-					if (eres == null) continue;
-					if (eres.Name == "objects.xml")
-						return true;
-				}
-			} catch {
-			}
-			return false;
+			return cache [path].HasWidgets;
 		}
 		
 		public static string FindAssembly (ImportContext importContext, string assemblyName, string basePath)
@@ -393,7 +379,7 @@
 			
 			AssemblyResolver res = new AssemblyResolver ();
 			try {
-				return res.Resolve (assemblyName, col);
+				return res.Resolve (AssemblyNameReference.Parse (assemblyName), col);
 			} catch {
 			}
 			return null;
@@ -426,7 +412,14 @@
 			EmbeddedResource res = GetResource (asm, "objects.xml");
 			if (res == null)
 				return list;
+			else
+				return GetComponentsFromResource (app, asm, res, fileName);
+		}
 				
+
+		static List<ComponentType> GetComponentsFromResource (Application app, AssemblyDefinition asm, EmbeddedResource res, string fileName)
+		{
+			List<ComponentType> list = new List<ComponentType> ();
 			MemoryStream ms = new MemoryStream (res.Data);
 			XmlDocument objects = new XmlDocument ();
 			objects.Load (ms);
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Application.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Application.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Application.cs	(revision 112335)
@@ -25,16 +25,172 @@
 	
 	public delegate string AssemblyResolverCallback (string assemblyName);
 	
-	public class Application: MarshalByRefObject, IDisposable
-	{
-		ApplicationBackend backend;
-		bool externalBackend;
+	public static class ApplicationFactory {
+
+		public static Application CreateApplication (IsolationMode mode)
+		{
+			switch (mode) {
+			case IsolationMode.None:
+				return new LocalApplication ();
+			case IsolationMode.ProcessTcp:
+			case IsolationMode.ProcessUnix:
+				return new IsolatedApplication (mode);
+			default:
+				throw new ArgumentException ("mode");
+			}
+		}
+	}
+
+	internal class IsolatedApplication : Application {
+
 		string channelId;
 		ApplicationBackendController backendController;
+
+		string RegisterRemotingChannel (IsolationMode mode)
+		{
+			string remotingChannel;
+			if (mode == IsolationMode.ProcessTcp) {
+				remotingChannel = "tcp";
+				IChannel ch = ChannelServices.GetChannel ("tcp");
+				if (ch == null) {
+					ChannelServices.RegisterChannel (new TcpChannel (0));
+				}
+			} else {
+				remotingChannel = "unix";
+				IChannel ch = ChannelServices.GetChannel ("unix");
+				if (ch == null) {
+					string unixRemotingFile = Path.GetTempFileName ();
+					ChannelServices.RegisterChannel (new UnixChannel (unixRemotingFile));
+				}
+			}
+			return remotingChannel;
+		}
+
+		public IsolatedApplication (IsolationMode mode)
+		{
+			if (mode == IsolationMode.None)
+				throw new ArgumentException ("mode");
+			channelId = RegisterRemotingChannel (mode);
+			backendController = new ApplicationBackendController (this, channelId);
+			backendController.StartBackend ();
+			OnBackendChanged (false);
+		}
+
+		public override void Dispose ()
+		{
+			base.Dispose ();
+			backendController.StopBackend (true);
+		}
+
+		public event BackendChangingHandler BackendChanging;
+		public event BackendChangedHandler BackendChanged;
 		
+		void OnNewBackendStarted (object ob, EventArgs args)
+		{
+			OnBackendChanging ();
+			ApplicationBackendController oldBackend = backendController;
+			backendController = (ApplicationBackendController) ob;
+			OnBackendChanged (true);
+			oldBackend.StopBackend (false);
+		}
+		
+		void OnBackendStopped (object ob, EventArgs args)
+		{
+			// The backend process crashed, try to restart it
+			Backend = null;
+			backendController = new ApplicationBackendController (this, channelId);
+			backendController.StartBackend ();
+			OnBackendChanged (true);
+		}
+		
+		void OnBackendChanged (bool notify)
+		{
+			ApplicationBackend oldBackend = Backend;
+			
+			Backend = backendController.Backend;
+			backendController.Stopped += OnBackendStopped;
+			UpdateWidgetLibraries (false, false);
+			ClearCollections ();
+			if (notify && BackendChanged != null)
+				BackendChanged (oldBackend);
+
+			Backend.ActiveProject = ActiveProject != null ? ActiveProject.ProjectBackend : null;
+		}
+		
+		void OnBackendChanging ()
+		{
+			Backend.GlobalWidgetLibraries = widgetLibraries;
+			if (BackendChanging != null)
+				BackendChanging ();
+		}
+
+		internal override void RestartBackend ()
+		{
+			// The backend process needs to be restarted.
+			// This is done in background.
+				
+			ThreadPool.QueueUserWorkItem (delegate {
+				try {
+					// Start the new backend
+					ApplicationBackendController newController = new ApplicationBackendController (this, channelId);
+					newController.StartBackend ();
+					Gtk.Application.Invoke (newController, EventArgs.Empty, OnNewBackendStarted);
+				} catch {
+					// FIXME: show an error message
+				}
+			});
+		}
+
+		internal override ComponentType CreateComponentType (string typeName)
+		{
+			string desc = null, className = null, category = null, targetGtkVersion = null, library = null;
+			Gdk.Pixbuf px = null;
+				
+			byte[] icon;
+					
+			if (Backend.GetClassDescriptorInfo (typeName, out desc, out className, out category, out targetGtkVersion, out library, out icon) && icon != null)
+				px = new Gdk.Pixbuf (icon);
+					
+			if (px == null)
+				px = ComponentType.Unknown.Icon;
+					
+			if (desc == null)
+				desc = typeName;
+
+			return new ComponentType (this, typeName, desc, className, category, targetGtkVersion, library, px);
+		}
+	}
+
+	internal class LocalApplication : Application {
+
+		public LocalApplication ()
+		{
+			Backend = new ApplicationBackend (this);
+		}
+
+		public override void Dispose ()
+		{
+			base.Dispose ();
+			Backend.Dispose ();
+		}
+
+		internal override ComponentType CreateComponentType (string typeName)
+		{
+			ClassDescriptor cls = Registry.LookupClassByName (typeName);
+			if (cls == null)
+				return null;
+				
+			return new ComponentType (this, typeName, cls.Label, cls.WrappedTypeName, cls.Category, cls.TargetGtkVersion, cls.Library.Name, cls.Icon);
+		}
+	}
+
+	public abstract class Application : MarshalByRefObject, IDisposable {
+
+		ApplicationBackend backend;
+
 		Hashtable components = new Hashtable ();
 		Hashtable types = new Hashtable ();
-		ArrayList widgetLibraries = new ArrayList ();
+		internal ArrayList widgetLibraries = new ArrayList ();
 		ArrayList projects = new ArrayList ();
 		Project activeProject;
 		Designer activeDesigner;
@@ -46,34 +202,14 @@
 		bool allowInProcLibraries = true;
 		bool disposed;
 		
-		static Hashtable libraryCheckCache; 
-		
-		internal event BackendChangingHandler BackendChanging;
-		internal event BackendChangedHandler BackendChanged;
-		internal event EventHandler Disposing;
-		
-		public Application (IsolationMode mode)
-		{
-			if (mode == IsolationMode.None) {
-				backend = new ApplicationBackend (this);
-				externalBackend = false;
-			} else {
-				externalBackend = true;
-				channelId = RegisterRemotingChannel (mode);
-				backendController = new ApplicationBackendController (this, channelId);
-				backendController.StartBackend ();
-				OnBackendChanged (false);
-			}
-		}
-		
 		public AssemblyResolverCallback WidgetLibraryResolver {
 			get { return Backend.WidgetLibraryResolver; }
 			set { Backend.WidgetLibraryResolver = value; }
 		}
 		
 		public bool ShowNonContainerWarning {
-			get { return backend.ShowNonContainerWarning; }
-			set { backend.ShowNonContainerWarning = value; }
+			get { return Backend.ShowNonContainerWarning; }
+			set { Backend.ShowNonContainerWarning = value; }
 		}
 		
 		// Loads the libraries registered in the projects or in the application.
@@ -84,67 +220,12 @@
 			UpdateWidgetLibraries (true, forceUnload);
 		}
 		
-		internal void UpdateWidgetLibraries (bool allowBackendRestart, bool forceUnload)
+		internal virtual void RestartBackend ()
 		{
-			// Collect libraries from the project and from the application
-			
-			ArrayList assemblies = new ArrayList ();
-			assemblies.AddRange (widgetLibraries);
-			
-			ArrayList projectBackends = new ArrayList ();
-			foreach (Project p in projects)
-				if (p.IsBackendLoaded)
-					projectBackends.Add (p.ProjectBackend);
-			
-			if (!Backend.UpdateLibraries (assemblies, projectBackends, allowBackendRestart, forceUnload))
-			{
-				// The backend process needs to be restarted.
-				// This is done in background.
-				
-				ThreadPool.QueueUserWorkItem (delegate {
-					try {
-						// Start the new backend
-						ApplicationBackendController newController = new ApplicationBackendController (this, channelId);
-						newController.StartBackend ();
-						Gtk.Application.Invoke (newController, EventArgs.Empty, OnNewBackendStarted);
-					} catch {
-						// FIXME: show an error message
-					}
-				});
-			}
 		}
-		
-		void OnNewBackendStarted (object ob, EventArgs args)
-		{
-			// The new backend is running, just do the switch
-			
-			OnBackendChanging ();
-			
-			ApplicationBackendController oldBackend = backendController;
-			backendController = (ApplicationBackendController) ob;
-			
-			OnBackendChanged (true);
 
-			// The old backend can now be safely stopped
-			oldBackend.StopBackend (false);
-		}
-		
-		void OnBackendStopped (object ob, EventArgs args)
+		protected void ClearCollections ()
 		{
-			// The backend process crashed, try to restart it
-			backend = null;
-			backendController = new ApplicationBackendController (this, channelId);
-			backendController.StartBackend ();
-			OnBackendChanged (true);
-		}
-		
-		void OnBackendChanged (bool notify)
-		{
-			ApplicationBackend oldBackend = backend;
-			
-			backend = backendController.Backend;
-			backendController.Stopped += OnBackendStopped;
-			UpdateWidgetLibraries (false, false);
 			lock (types) {
 				types.Clear ();
 			}
@@ -161,79 +242,70 @@
 			foreach (Component c in comps) {
 				c.Dispose ();
 			}
-
-			if (notify && BackendChanged != null)
-				BackendChanged (oldBackend);
-
-			backend.ActiveProject = activeProject != null ? activeProject.ProjectBackend : null;
 		}
-		
-		void OnBackendChanging ()
+
+		internal void UpdateWidgetLibraries (bool allowBackendRestart, bool forceUnload)
 		{
-			backend.GlobalWidgetLibraries = widgetLibraries;
-			if (BackendChanging != null)
-				BackendChanging ();
+			// Collect libraries from the project and from the application
+			
+			ArrayList assemblies = new ArrayList ();
+			assemblies.AddRange (widgetLibraries);
+			
+			ArrayList projectBackends = new ArrayList ();
+			foreach (Project p in projects)
+				if (p.IsBackendLoaded)
+					projectBackends.Add (p.ProjectBackend);
+			
+			if (!Backend.UpdateLibraries (assemblies, projectBackends, allowBackendRestart, forceUnload))
+				RestartBackend ();
 		}
 		
-		internal string RegisterRemotingChannel (IsolationMode mode)
-		{
-			string remotingChannel;
-			if (mode == IsolationMode.ProcessTcp) {
-				remotingChannel = "tcp";
-				IChannel ch = ChannelServices.GetChannel ("tcp");
-				if (ch == null) {
-					ChannelServices.RegisterChannel (new TcpChannel (0));
-				}
-			} else {
-				remotingChannel = "unix";
-				IChannel ch = ChannelServices.GetChannel ("unix");
-				if (ch == null) {
-					string unixRemotingFile = Path.GetTempFileName ();
-					ChannelServices.RegisterChannel (new UnixChannel (unixRemotingFile));
-				}
-			}
-			return remotingChannel;
-		}
-		
 		public virtual void Dispose ()
 		{
 			if (disposed)
 				return;
 				
 			disposed = true;
-			if (Disposing != null)
-				Disposing (this, EventArgs.Empty);
-			if (externalBackend) {
-				backendController.StopBackend (true);
-			} else {
-				backend.Dispose ();
-			}
+			ClearCollections ();
+			ArrayList copy = (ArrayList) projects.Clone ();
+			foreach (Project p in copy)
+				p.Dispose ();
+			if (propertiesWidget != null)
+				 propertiesWidget.Destroy ();
+			if (paletteWidget != null)
+				 paletteWidget.Destroy ();
+			if (projectWidget != null)
+				 projectWidget.Destroy ();
+			if (signalsWidget != null)
+				 signalsWidget.Destroy ();
+			widgetLibraries.Clear ();
 			System.Runtime.Remoting.RemotingServices.Disconnect (this);
 		}
 		
-		internal bool Disposed {
-			get { return disposed; }
-		}
-
 		public override object InitializeLifetimeService ()
 		{
 			// Will be disconnected when calling Dispose
 			return null;
 		}
 		
-		internal ApplicationBackend Backend {
-			get {
-				if (disposed)
-					throw new InvalidOperationException ("Application has been disposed");
-				return backend;
-			}
+		internal ApplicationBackend Backend { 
+			get { return backend; }
+			set { backend = value; }
 		}
 		
+		void ProjectDisposed (object sender, EventArgs args)
+		{
+			projects.Remove (sender as Project);
+			if (!disposed)
+				UpdateWidgetLibraries (false, false);
+		}
+		
 		public Project LoadProject (string path)
 		{
 			Project p = new Project (this);
 			p.Load (path);
 			projects.Add (p);
+			p.Disposed += ProjectDisposed;
 			return p;
 		}
 		
@@ -241,6 +313,7 @@
 		{
 			Project p = new Project (this);
 			projects.Add (p);
+			p.Disposed += ProjectDisposed;
 			return p;
 		}
 		
@@ -256,7 +329,7 @@
 		{
 			if (!widgetLibraries.Contains (assemblyPath)) {
 				widgetLibraries.Add (assemblyPath);
-				Backend.GlobalWidgetLibraries = widgetLibraries; 
+				Backend.GlobalWidgetLibraries = widgetLibraries;
 				UpdateWidgetLibraries (false, false);
 			}
 		}
@@ -264,7 +337,7 @@
 		public void RemoveWidgetLibrary (string assemblyPath)
 		{
 			widgetLibraries.Remove (assemblyPath);
-			Backend.GlobalWidgetLibraries = widgetLibraries; 
+			Backend.GlobalWidgetLibraries = widgetLibraries;
 			UpdateWidgetLibraries (false, false);
 		}
 		
@@ -277,7 +350,7 @@
 		{
 			ImportContext ic = new ImportContext ();
 			ic.App = this.Backend;
-			return Application.InternalIsWidgetLibrary (ic, assemblyRef);
+			return InternalIsWidgetLibrary (ic, assemblyRef);
 		}
 		
 		internal static bool InternalIsWidgetLibrary (ImportContext ic, string assemblyRef)
@@ -294,22 +367,10 @@
 				if (path == null)
 					return false;
 			}
-			
-			LibraryData data = GetLibraryCacheData (path);
-			if (data == null) {
-				// There is no info about this library, it has to be checked
-				bool isLib = CecilWidgetLibrary.IsWidgetLibrary (path);
-				SetLibraryCacheData (path, isLib);
-				return isLib;
-			} else
-				return data.IsLibrary;
+
+			return CecilWidgetLibrary.IsWidgetLibrary (path);
 		}
 		
-		internal void DisposeProject (Project p)
-		{
-			projects.Remove (p);
-		}
-		
 		public CodeGenerationResult GenerateProjectCode (string file, string namespaceName, CodeDomProvider provider, GenerationOptions options, params Project[] projects)
 		{
 			ArrayList files = new ArrayList ();
@@ -361,10 +422,6 @@
 			}
 		}
 		
-		internal bool UseExternalBackend {
-			get { return externalBackend; }
-		}
-			
 		internal Project ActiveProject {
 			get { return activeProject; }
 			set { 
@@ -383,32 +440,40 @@
 		
 		public WidgetPropertyTree PropertiesWidget {
 			get {
-				if (propertiesWidget == null)
+				if (propertiesWidget == null) {
 					propertiesWidget = new WidgetPropertyTree (this);
+					propertiesWidget.Destroyed += delegate { propertiesWidget = null; };
+				}
 				return propertiesWidget;
 			}
 		}
 		
 		public Palette PaletteWidget {
 			get {
-				if (paletteWidget == null)
+				if (paletteWidget == null) {
 					paletteWidget = new Palette (this);
+					paletteWidget.Destroyed += delegate { paletteWidget = null; };
+				}
 				return paletteWidget;
 			}
 		}
 		
 		public WidgetTree WidgetTreeWidget {
 			get {
-				if (projectWidget == null)
+				if (projectWidget == null) {
 					projectWidget = new WidgetTree (this);
+					projectWidget.Destroyed += delegate { projectWidget = null; };
+				}
 				return projectWidget;
 			}
 		}
 		
 		public SignalsEditor SignalsWidget {
 			get {
-				if (signalsWidget == null)
+				if (signalsWidget == null) {
 					signalsWidget = new SignalsEditor (this);
+					signalsWidget.Destroyed += delegate { signalsWidget = null; };
+				}
 				return signalsWidget;
 			}
 		}
@@ -436,6 +501,8 @@
 			}
 		}
 		
+		internal abstract ComponentType CreateComponentType (string typeName);
+
 		internal ComponentType GetComponentType (string typeName)
 		{
 			lock (types) {
@@ -448,36 +515,7 @@
 					return t;
 				}
 				
-				string desc = null, className = null, category = null, targetGtkVersion = null, library = null;
-				Gdk.Pixbuf px = null;
-				
-				if (externalBackend) {
-					byte[] icon;
-					
-					if (Backend.GetClassDescriptorInfo (typeName, out desc, out className, out category, out targetGtkVersion, out library, out icon)) {
-						if (icon != null)
-							px = new Gdk.Pixbuf (icon);
-					}
-					
-					if (px == null) {
-						px = ComponentType.Unknown.Icon;
-					}
-					
-					if (desc == null)
-						desc = typeName;
-				} else {
-					ClassDescriptor cls = Registry.LookupClassByName (typeName);
-					if (cls != null) {
-						desc = cls.Label;
-						className = cls.WrappedTypeName;
-						category = cls.Category;
-						targetGtkVersion = cls.TargetGtkVersion;
-						px = cls.Icon;
-						library = cls.Library.Name;
-					}
-				}
-				
-				t = new ComponentType (this, typeName, desc, className, category, targetGtkVersion, library, px);
+				t = CreateComponentType (typeName);
 				types [typeName] = t;
 				return t;
 			}
@@ -531,97 +569,6 @@
 			}
 		}
 		
-		static LibraryData GetLibraryCacheData (string path)
-		{
-			if (libraryCheckCache == null)
-				LoadLibraryCheckCache ();
-			LibraryData data = (LibraryData) libraryCheckCache [path];
-			if (data == null)
-				return null;
-
-			DateTime lastWrite = File.GetLastWriteTime (path);
-			if (data.LastCheck == lastWrite)
-				return data;
-			else
-				// Data not valid anymore
-				return null;
-		}
-		
-		static void SetLibraryCacheData (string path, bool isLibrary)
-		{
-			if (libraryCheckCache == null)
-				LoadLibraryCheckCache ();
-
-			LibraryData data = (LibraryData) libraryCheckCache [path];
-			if (data == null) {
-				data = new LibraryData ();
-				libraryCheckCache [path] = data;
-			}
-			data.IsLibrary = isLibrary;
-			data.LastCheck = File.GetLastWriteTime (path);
-			SaveLibraryCheckCache ();
-		}
-		
-		static void LoadLibraryCheckCache ()
-		{
-			bool needsSave = false;;
-			libraryCheckCache = new Hashtable ();
-			string cacheFile = Path.Combine (ConfigDir, "assembly-check-cache");
-			if (!File.Exists (cacheFile))
-				return;
-			
-			try {
-				XmlDocument doc = new XmlDocument ();
-				doc.Load (cacheFile);
-				foreach (XmlElement elem in doc.SelectNodes ("assembly-check-cache/assembly")) {
-					string file = elem.GetAttribute ("path");
-					if (File.Exists (file)) {
-						LibraryData data = new LibraryData ();
-						if (elem.GetAttribute ("isLibrary") == "yes")
-							data.IsLibrary = true;
-						data.LastCheck = XmlConvert.ToDateTime (elem.GetAttribute ("timestamp"), XmlDateTimeSerializationMode.Local);
-					} else
-						needsSave = true;
-				}
-			} catch {
-				// If there is an error, just ignore the cached data
-				needsSave = true;
-			}
-			
-			if (needsSave)
-				SaveLibraryCheckCache ();
-		}
-		
-		static void SaveLibraryCheckCache ()
-		{
-			if (libraryCheckCache == null)
-				return;
-			
-			try {
-				if (!Directory.Exists (ConfigDir))
-					Directory.CreateDirectory (ConfigDir);
-					
-				XmlDocument doc = new XmlDocument ();
-				XmlElement delem = doc.CreateElement ("assembly-check-cache");
-				doc.AppendChild (delem);
-					
-				foreach (DictionaryEntry e in libraryCheckCache) {
-					LibraryData data = (LibraryData) e.Value;
-					XmlElement elem = doc.CreateElement ("assembly");
-					elem.SetAttribute ("path", (string) e.Key);
-					if (data.IsLibrary)
-						elem.SetAttribute ("isLibrary", "yes");
-					elem.SetAttribute ("timestamp", XmlConvert.ToString (data.LastCheck, XmlDateTimeSerializationMode.Local));
-					delem.AppendChild (elem);
-				}
-				
-				doc.Save (Path.Combine (ConfigDir, "assembly-check-cache"));
-			}
-			catch {
-				// If something goes wrong, just ignore the cached info
-			}
-		}
-		
 		static string ConfigDir {
 			get { 
 				string file = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config");
@@ -632,10 +579,4 @@
 
 	internal delegate void BackendChangingHandler ();
 	internal delegate void BackendChangedHandler (ApplicationBackend oldBackend);
-	
-	class LibraryData
-	{
-		public DateTime LastCheck;
-		public bool IsLibrary;
-	}
 }
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ApplicationBackendController.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ApplicationBackendController.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/ApplicationBackendController.cs	(revision 112335)
@@ -15,13 +15,13 @@
 		bool stopping;
 		ApplicationBackend backend;
 		string channelId;
-		Application app;
+		IsolatedApplication app;
 		
 		ManualResetEvent runningEvent = new ManualResetEvent (false);
 		
 		public event EventHandler Stopped;
 		
-		public ApplicationBackendController (Application app, string channelId)
+		public ApplicationBackendController (IsolatedApplication app, string channelId)
 		{
 			this.app = app;
 			this.channelId = channelId;
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Project.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Project.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/Project.cs	(revision 112335)
@@ -54,8 +54,11 @@
 				backend.SetFrontend (this);
 			}
 
-			app.BackendChanging += OnBackendChanging;
-			app.BackendChanged += OnBackendChanged;
+			if (app is IsolatedApplication) {
+				IsolatedApplication iapp = app as IsolatedApplication;
+				iapp.BackendChanging += OnBackendChanging;
+				iapp.BackendChanged += OnBackendChanged;
+			}
 		}
 		
 		internal ProjectBackend ProjectBackend {
@@ -80,10 +83,15 @@
 			get { return app; }
 		}
 		
+		internal event EventHandler Disposed;
+
 		public void Dispose ()
 		{
-			app.BackendChanging -= OnBackendChanging;
-			app.BackendChanged -= OnBackendChanged;
+			if (app is IsolatedApplication) {
+				IsolatedApplication iapp = app as IsolatedApplication;
+				iapp.BackendChanging -= OnBackendChanging;
+				iapp.BackendChanged -= OnBackendChanged;
+			}
 			
 			if (tmpProjectFile != null && File.Exists (tmpProjectFile)) {
 				File.Delete (tmpProjectFile);
@@ -91,9 +99,9 @@
 			}
 			if (backend != null)
 				backend.Dispose ();
-			app.DisposeProject (this);
+			if (Disposed != null)
+				Disposed (this, EventArgs.Empty);
 			System.Runtime.Remoting.RemotingServices.Disconnect (this);
-			app.UpdateWidgetLibraries (false, false);
 		}
 
 		public override object InitializeLifetimeService ()
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/PluggableWidget.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/PluggableWidget.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libsteticui/PluggableWidget.cs	(revision 112335)
@@ -20,9 +20,9 @@
 			Add (book);
 			
 			this.app = app;
-			if (app.UseExternalBackend) {
-				app.BackendChanged += OnBackendChanged;
-				app.BackendChanging += OnBackendChanging;
+			if (app is IsolatedApplication) {
+				(app as IsolatedApplication).BackendChanged += OnBackendChanged;
+				(app as IsolatedApplication).BackendChanging += OnBackendChanging;
 			}
 		}
 		
@@ -50,9 +50,9 @@
 		protected override void OnRealized ()
 		{
 			base.OnRealized ();
-			if (!initialized && !app.Disposed) {
+			if (!initialized) {
 				initialized = true;
-				if (app.UseExternalBackend)
+				if (app is IsolatedApplication)
 					ConnectPlug ();
 				else {
 					Gtk.Widget w = OnCreateWidget ();
@@ -64,7 +64,7 @@
 		
 		protected override void OnUnrealized ()
 		{
-			if (!app.Disposed && app.UseExternalBackend && initialized) {
+			if (app is IsolatedApplication && initialized) {
 				OnDestroyPlug (socket.Id);
 				initialized = false;
 			}
@@ -93,10 +93,10 @@
 		
 		protected void UpdateWidget ()
 		{
-			if (!initialized || app.Disposed)
+			if (!initialized)
 				return;
 
-			if (!app.UseExternalBackend) {
+			if (app is LocalApplication) {
 				Gtk.Widget w = OnCreateWidget ();
 				if (w.Parent != book) {
 					book.AppendPage (w, null);
@@ -119,25 +119,24 @@
 		
 		public override void Dispose ()
 		{
-			if (app.UseExternalBackend) {
-				app.BackendChanged -= OnBackendChanged;
-				app.BackendChanging -= OnBackendChanging;
+			if (app is IsolatedApplication) {
+				IsolatedApplication iapp = app as IsolatedApplication;
+				iapp.BackendChanged -= OnBackendChanged;
+				iapp.BackendChanging -= OnBackendChanging;
 			}
 			base.Dispose ();
 		}
 		
 		internal virtual void OnBackendChanged (ApplicationBackend oldBackend)
 		{
-			if (!initialized || app.Disposed)
+			if (!initialized)
 				return;
 
-			if (app.UseExternalBackend) {
-				Gtk.Widget w = book.GetNthPage (0);
-				book.RemovePage (0);
-				w.Destroy ();
-				socket.Dispose ();
-				ConnectPlug ();
-			}
+			Gtk.Widget w = book.GetNthPage (0);
+			book.RemovePage (0);
+			w.Destroy ();
+			socket.Dispose ();
+			ConnectPlug ();
 		}
 		
 		internal virtual void OnBackendChanging ()
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Widget.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Widget.cs	(revision 112335)
@@ -98,6 +98,9 @@
 		
 		public override void Dispose ()
 		{
+			if (Wrapped == null)
+				return;
+
 			if (Project != null && Project.Selection == Wrapped)
 				Project.Selection = null;
 
@@ -109,6 +112,7 @@
 			if (actionGroups != null) {
 				foreach (ActionGroup ag in actionGroups)
 					ag.Dispose ();
+				actionGroups = null;
 			}
 			base.Dispose ();
 		}
@@ -213,7 +217,7 @@
 		
 		public new Gtk.Widget Wrapped {
 			get {
-				return (Gtk.Widget)base.Wrapped;
+				return base.Wrapped as Gtk.Widget;
 			}
 		}
 
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Object.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Object.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/Object.cs	(revision 112335)
@@ -6,6 +6,8 @@
 
 		public override void Dispose ()
 		{
+			if (Wrapped == null)
+				return;
 			((GLib.Object)Wrapped).RemoveNotification (NotifyHandler);
 			base.Dispose ();
 		}
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/objects.xml
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/objects.xml	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/objects.xml	(revision 112335)
@@ -215,8 +215,8 @@
 	    <itemgroup label="Miscellaneous Alignment Properties">
 		<property name="Xpad" />
 		<property name="Ypad" />
-		<property name="Xalign" />
-		<property name="Yalign" />
+		<property name="Xalign" min="0.0" max="1.0" />
+		<property name="Yalign" min="0.0" max="1.0" />
 		<command name="AlignLeft" label="Align Left" icon="gtk-justify-left" />
 		<command name="AlignCenter" label="Align Center" icon="gtk-justify-center" />
 		<command name="AlignRight" label="Align Right" icon="gtk-justify-right" />
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/ActionToolbarWrapper.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/ActionToolbarWrapper.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/ActionToolbarWrapper.cs	(revision 112335)
@@ -52,6 +52,7 @@
 		{
 			base.Wrap (obj, initialized);
 			CreateTree ();
+			toolbar.FillMenu (actionTree);
 		}
 		
 		public override bool HExpandable {
@@ -270,7 +271,7 @@
 		{
 			actionTree = new ActionTree ();
 			actionTree.Name = Wrapped.Name;
-			actionTree.Type = Gtk.UIManagerItemType.Menubar;
+			actionTree.Type = Gtk.UIManagerItemType.Toolbar;
 			actionTree.Changed += OnTreeChanged;
 		}
 		
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionMenuItem.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionMenuItem.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionMenuItem.cs	(revision 112335)
@@ -42,8 +42,13 @@
 			CreateControls ();
 		}
 		
+		bool disposed;
+
 		public override void Dispose ()
 		{
+			if (disposed)
+				return;
+			disposed = true;
 			if (menuBarItem != null) {
 				menuBarItem.ButtonPressEvent -= OnMenuItemPress;
 				menuBarItem.ButtonReleaseEvent -= OnMemuItemRelease;
@@ -289,6 +294,9 @@
 		
 		public void Detach ()
 		{
+			if (disposed)
+				return;
+
 			Gtk.Table table = (Gtk.Table)Parent;
 			if (table == null)
 				return;
Index: src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionGroupEditor.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionGroupEditor.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/editor/ActionGroupEditor.cs	(revision 112335)
@@ -16,6 +16,7 @@
 		EditableLabel headerLabel;
 		uint columns = 2;
 		bool modified;
+		bool disposed;
 		ObjectWrapperEventHandler changedEvent;
 		IDesignArea darea;
 		
@@ -58,6 +59,9 @@
 		
 		public override void Dispose ()
 		{
+			if (disposed)
+				return;
+			disposed = true;
 			headerLabel.Changed -= OnGroupNameChanged;
 			if (emptyLabel != null)
 				emptyLabel.ButtonPressEvent -= OnAddClicked;
@@ -100,7 +104,8 @@
 					foreach (Wrapper.Action a in actionGroup.Actions)
 						a.ObjectChanged += changedEvent;
 				}
-				Fill ();
+				if (!disposed)
+					Fill ();
 			}
 		}
 		
Index: src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
===================================================================
--- src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs	(revision 97933)
+++ src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs	(revision 112335)
@@ -96,7 +96,7 @@
 		public static Stetic.Application SteticApp {
 			get {
 				if (steticApp == null) {
-					steticApp = new Stetic.Application (IsolationMode);
+					steticApp = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
 					steticApp.AllowInProcLibraries = false;
 					steticApp.ShowNonContainerWarning = PropertyService.Get ("MonoDevelop.GtkCore.ShowNonContainerWarning", true);
 					steticApp.WidgetLibraryResolver = OnAssemblyResolve;
@@ -520,7 +520,7 @@
 		{
 			Gtk.Application.Init ();
 			
-			Stetic.Application app = new Stetic.Application (Stetic.IsolationMode.None);
+			Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
 			
 			Stetic.Project[] projects = new Stetic.Project [projectFiles.Count];
 			for (int n=0; n < projectFiles.Count; n++) {
Index: src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Dialogs/CommitDialog.cs
===================================================================
--- src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Dialogs/CommitDialog.cs	(revision 97933)
+++ src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Dialogs/CommitDialog.cs	(revision 112335)
@@ -160,11 +160,5 @@
 			else
 				selected.Remove (vinfo.LocalPath);
 		}
-		
-		public override void Dispose ()
-		{
-			base.Dispose ();
-			Destroy ();
-		}
 	}
 }
Index: src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorWidget.cs
===================================================================
--- src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorWidget.cs	(revision 97933)
+++ src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorWidget.cs	(revision 112335)
@@ -59,10 +59,10 @@
 			Add (View);
 		}
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
 			Buffer.Dispose ();
-			base.Dispose ();
+			base.OnDestroyed ();
 		}
 
 		public void ExecutingAt (int linenumber)
Index: src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs
===================================================================
--- src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs	(revision 97933)
+++ src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs	(revision 112335)
@@ -262,7 +262,7 @@
 			InitAutoCorrectionValues();
 		}
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
 			if (showTipScheduled)
 				GLib.Source.Remove (tipTimeoutId);
@@ -272,7 +272,7 @@
 			buf.Changed -= new EventHandler (BufferChanged);
 			CleanAutoCorrectionValues();
 			
-			base.Dispose ();
+			base.OnDestroyed ();
 		}
 		
 		public ITextEditorExtension AttachExtension (ITextEditorExtension extension)
Index: src/addins/NUnit/Services/NUnitService.cs
===================================================================
--- src/addins/NUnit/Services/NUnitService.cs	(revision 97933)
+++ src/addins/NUnit/Services/NUnitService.cs	(revision 112335)
@@ -107,7 +107,29 @@
 			return session;
 		}
 		
+		public UnitTest SearchTest (string fullName)
+		{
+			return SearchTest (rootTest, fullName);
+		}
 		
+		UnitTest SearchTest (UnitTest test, string fullName)
+		{
+			if (test == null)
+				return null;
+			if (test.FullName == fullName)
+				return test;
+			
+			UnitTestGroup group = test as UnitTestGroup;
+			if (group != null)  {
+				foreach (UnitTest t in group.Tests) {
+					UnitTest result = SearchTest (t, fullName);
+					if (result != null)
+						return result;
+				}
+			}
+			return null;
+		}
+		
 		protected virtual void OnOpenCombine (object sender, CombineEventArgs e)
 		{
 			rootTest = BuildTest (e.Combine);
Index: src/addins/NUnit/Gui/TestResultsPad.cs
===================================================================
--- src/addins/NUnit/Gui/TestResultsPad.cs	(revision 97933)
+++ src/addins/NUnit/Gui/TestResultsPad.cs	(revision 112335)
@@ -143,6 +143,7 @@
 			
 			buttonRun = new ToolButton (new Gtk.Image (Gtk.Stock.Execute, IconSize.Menu), GettextCatalog.GetString ("Run Test"));
 			buttonRun.IsImportant = true;
+			buttonRun.Sensitive = false;
 			toolbar.Insert (buttonRun, -1);
 			
 			buttonStop = new ToolButton (Gtk.Stock.Stop);
@@ -242,6 +243,11 @@
 			testsFailed = 0;
 			testsIgnored = 0;
 			UpdateCounters ();
+			if (rootTest != null) {
+				rootTest = testService.SearchTest (rootTest.FullName);
+				if (rootTest == null)
+					buttonRun.Sensitive = false;
+			}
 		}
 		
 		bool Running {
@@ -362,6 +368,8 @@
 		
 		void OnRunClicked (object sender, EventArgs args)
 		{
+			if (rootTest == null)
+				return;
 			NUnitService testService = (NUnitService) ServiceManager.GetService (typeof(NUnitService));
 			testService.RunTest (rootTest);
 		}
Index: src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs
===================================================================
--- src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs	(revision 97933)
+++ src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexLibraryWindow.cs	(revision 112335)
@@ -74,11 +74,6 @@
 			UpdateExpressions ();
 		}
 		
-		public override void Dispose ()
-		{
-			base.Dispose ();
-		}
-		
 		void ShowSelectedEntry ()
 		{
 			TreeIter iter;
Index: src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexToolkitWindow.cs
===================================================================
--- src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexToolkitWindow.cs	(revision 97933)
+++ src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexToolkitWindow.cs	(revision 112335)
@@ -195,15 +195,10 @@
 			}
 		}
 		
-		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
-			base.Dispose ();
+			base.OnDestroyed ();
 			HideTooltipWindow ();
-			if (regexLib != null) {
-				regexLib.Destroy ();
-				regexLib = null;
-			}
 		}
 
 		
Index: src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs
===================================================================
--- src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs	(revision 97933)
+++ src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs	(revision 112335)
@@ -507,13 +507,10 @@
 		}
 #endregion
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
 			widgets.Remove (this);
-			this.headersEditor.Destroy ();
-			this.headersEditor = null;
-			
-			base.Dispose ();
+			base.OnDestroyed ();
 		}
 	}
 }
Index: src/addins/CSharpBinding/Parser/CodeGenerator.cs
===================================================================
--- src/addins/CSharpBinding/Parser/CodeGenerator.cs	(revision 97933)
+++ src/addins/CSharpBinding/Parser/CodeGenerator.cs	(revision 112335)
@@ -33,6 +33,7 @@
 using System.Drawing;
 using System.CodeDom;
 using System.Collections;
+using System.Collections.Generic;
 using System.CodeDom.Compiler;
 using System.Text.RegularExpressions;
 using Microsoft.CSharp;
@@ -485,13 +486,23 @@
 		
 		bool IsExpectedClass (IClass type)
 		{
+			return IsExpectedClass (type, new Dictionary<string,string> ());
+		}
+		
+		bool IsExpectedClass (IClass type, Dictionary<string,string> checkedTypes)
+		{
+			if (checkedTypes.ContainsKey (type.FullyQualifiedName))
+				return false;
+			
 			if (type.FullyQualifiedName == declaringType.FullyQualifiedName)
 				return true;
 			
+			checkedTypes [type.FullyQualifiedName] = type.FullyQualifiedName;
+			
 			if (type.BaseTypes != null) {
 				foreach (IReturnType bc in type.BaseTypes) {
 					IClass bcls = ctx.ParserContext.GetClass (bc.FullyQualifiedName, bc.GenericArguments, true, true);
-					if (bcls != null && IsExpectedClass (bcls))
+					if (bcls != null && IsExpectedClass (bcls, checkedTypes))
 						return true;
 				}
 			}
Index: src/core/MonoDevelop.Projects/MonoDevelop.Projects/BuildTool.cs
===================================================================
--- src/core/MonoDevelop.Projects/MonoDevelop.Projects/BuildTool.cs	(revision 97933)
+++ src/core/MonoDevelop.Projects/MonoDevelop.Projects/BuildTool.cs	(revision 112335)
@@ -50,10 +50,14 @@
 				ReadArgument (s);
 			
 			if (help) {
-				Console.WriteLine ("build [options] [project-file]");
-				Console.WriteLine ("--f --buildfile:FILE   Project or solution file to build.");
-				Console.WriteLine ("--p --project:PROJECT  Name of the project to build.");
+				Console.WriteLine ("build [options] [target]");
+				Console.WriteLine ("-f --buildfile:FILE   Project or solution file to build.");
+				Console.WriteLine ("-p --project:PROJECT  Name of the project to build.");
 				Console.WriteLine ();
+				Console.WriteLine ("Supported targets:");
+				Console.WriteLine ("  build: build the project (the default target).");
+				Console.WriteLine ("  clean: clean the project.");
+				Console.WriteLine ();
 				return 0;
 			}
 			
Index: src/core/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.ProgressMonitoring/BaseProgressMonitor.cs
===================================================================
--- src/core/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.ProgressMonitoring/BaseProgressMonitor.cs	(revision 97933)
+++ src/core/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.ProgressMonitoring/BaseProgressMonitor.cs	(revision 112335)
@@ -151,6 +151,9 @@
 		[AsyncDispatch]
 		public virtual void Dispose()
 		{
+			// Make sure we are done with all pending calls
+			DispatchService.RunPendingEvents ();
+			
 			lock (progressTracker) {
 				progressTracker.Done ();
 				if (c.waitEvent != null)
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateGroup.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateGroup.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplateGroup.cs	(revision 112335)
@@ -95,6 +95,8 @@
 						break;
 					}
 				}
+				else
+					break;
 			}
 			return result;
 		}
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs	(revision 112335)
@@ -304,7 +304,8 @@
 				return false;
 			} else {
 				foreach (FileDescriptionTemplate newfile in Files)
-					CreateFile (newfile, project, directory, language, name);
+					if (!CreateFile (newfile, project, directory, language, name))
+						return false;
 				return true;
 			}
 		}
@@ -322,11 +323,13 @@
 			return valid;
 		}
 		
-		protected virtual void CreateFile (FileDescriptionTemplate newfile, Project project, string directory, string language, string name)
+		protected virtual bool CreateFile (FileDescriptionTemplate newfile, Project project, string directory, string language, string name)
 		{
 			if (project != null) {
-				newfile.AddToProject (project, language, directory, name);
-				newfile.Show ();
+				if (newfile.AddToProject (project, language, directory, name)) {
+					newfile.Show ();
+					return true;
+				}
 			} else {
 				SingleFileDescriptionTemplate singleFile = newfile as SingleFileDescriptionTemplate;
 				if (singleFile == null)
@@ -334,7 +337,10 @@
 				
 				if (directory != null) {
 					string fileName = singleFile.SaveFile (project, language, directory, name);
-					IdeApp.Workbench.OpenDocument (fileName);
+					if (fileName != null) {
+						IdeApp.Workbench.OpenDocument (fileName);
+						return true;
+					}
 				} else {
 					string fileName = singleFile.GetFileName (project, language, directory, name);
 					Stream stream = singleFile.CreateFile (project, language, fileName);
@@ -352,8 +358,10 @@
 						mimeType = "text";
 					
 					IdeApp.Workbench.NewDocument (fileName, mimeType, stream);
+					return true;
 				}
 			}
+			return false;
 		}
 		
 		protected virtual bool IsValidForProject (Project project, string projectPath)
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs	(revision 112335)
@@ -76,12 +76,24 @@
 		public abstract string Name { get; }
 		
 		public abstract void Load (XmlElement filenode);
-		public abstract void AddToProject (Project project, string language, string directory, string name);
+		public abstract bool AddToProject (Project project, string language, string directory, string name);
 		public abstract void Show ();
 		
 		public virtual bool IsValidName (string name, string language)
 		{
-			return (name.Length > 0);
+			if (name.Length > 0) {
+				if (language != null && language.Length > 0) {
+					IDotNetLanguageBinding binding = MonoDevelop.Projects.Services.Languages.GetBindingPerLanguageName (language) as IDotNetLanguageBinding;
+					if (binding != null) {
+						System.CodeDom.Compiler.CodeDomProvider provider = binding.GetCodeDomProvider ();
+						if (provider != null)
+							return provider.IsValidIdentifier (provider.CreateEscapedIdentifier (name));
+					}
+				}
+				return name.IndexOfAny (Path.GetInvalidFileNameChars ()) == -1;
+			}
+			else
+				return false;
 		}
 		
 		public virtual bool SupportsProject (Project project, string projectPath)
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs	(revision 112335)
@@ -87,9 +87,9 @@
 			set { addStandardHeader = value; }
 		}
 		
-		public sealed override void AddToProject (Project project, string language, string directory, string name)
+		public sealed override bool AddToProject (Project project, string language, string directory, string name)
 		{
-			AddFileToProject (project, language, directory, name);
+			return AddFileToProject (project, language, directory, name) != null;
 		}
 		
 		public ProjectFile AddFileToProject (Project project, string language, string directory, string name)
@@ -303,22 +303,5 @@
 			
 			return tagsArr;
 		}
-		
-		public override bool IsValidName (string name, string language)
-		{
-			if (name.Length > 0) {
-				if (language != null && language.Length > 0) {
-					IDotNetLanguageBinding binding = GetLanguageBinding (language) as IDotNetLanguageBinding;
-					if (binding != null) {
-						System.CodeDom.Compiler.CodeDomProvider provider = binding.GetCodeDomProvider ();
-						if (provider != null)
-							return provider.IsValidIdentifier (provider.CreateEscapedIdentifier (name));
-					}
-				}
-				return name.IndexOfAny (Path.GetInvalidFileNameChars ()) == -1;
-			}
-			else
-				return false;
-		}
 	}
 }
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs	(revision 112335)
@@ -52,10 +52,15 @@
 			}
 		}
 		
-		public override void AddToProject (Project project, string language, string directory, string name)
+		public override bool AddToProject (Project project, string language, string directory, string name)
 		{
 			ProjectFile file = template.AddFileToProject (project, language, directory, name);
-			file.BuildAction = BuildAction.EmbedAsResource;
+			if (file != null) {
+				file.BuildAction = BuildAction.EmbedAsResource;
+				return true;
+			}
+			else
+				return false;
 		}
 		
 		public override void Show ()
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs	(revision 112335)
@@ -58,10 +58,13 @@
 			get { return name;}
 		}
 		
-		public override void AddToProject (Project project, string language, string directory, string nameNotUsed)
+		public override bool AddToProject (Project project, string language, string directory, string nameNotUsed)
 		{
-			foreach (FileDescriptionTemplate fdt in innerTemplate.Files)
-				fdt.AddToProject (project, language, directory, this.name);
+			foreach (FileDescriptionTemplate fdt in innerTemplate.Files) {
+				if (!fdt.AddToProject (project, language, directory, this.name))
+					return false;
+			}
+			return true;
 		}
 		
 		public override void Show ()
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/SplashScreen.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/SplashScreen.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/SplashScreen.cs	(revision 112335)
@@ -9,7 +9,7 @@
 
 namespace MonoDevelop.Ide.Gui.Dialogs {
 	
-	public class SplashScreenForm : Gtk.Window, IProgressMonitor
+	public class SplashScreenForm : Gtk.Window, IProgressMonitor, IDisposable
 	{
 		static SplashScreenForm splashScreen;
 		static ProgressBar progress;
@@ -135,10 +135,9 @@
 			get { return this; }
 		}
 		
-		public override void Dispose ()
+		void IDisposable.Dispose ()
 		{
 			Destroy ();
-			base.Dispose ();
 		}
 	}
 }
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/FileSelectorDialog.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/FileSelectorDialog.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/FileSelectorDialog.cs	(revision 112335)
@@ -301,14 +301,14 @@
 			FillViewers ();
 		}
 		
-		public override void Dispose ()
+		protected override void OnDestroyed ()
 		{
 			// Save active filter
 			string pattern = filterPairs[this.Filter.Name] as string;
 			if (pattern != null)
 				PropertyService.Set ("Monodevelop.FileSelector.LastPattern", pattern);
 
-			base.Dispose ();
+			base.OnDestroyed ();
 		}
 	}
 }
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs	(revision 112335)
@@ -96,12 +96,6 @@
 			}
 		}
 		
-		public override void Dispose ()
-		{
-			Destroy ();
-			base.Dispose ();
-		}
-		
 		void InitializeView()
 		{
 			PixbufList smalllist  = new PixbufList();
Index: src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewFileDialog.cs
===================================================================
--- src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewFileDialog.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewFileDialog.cs	(revision 112335)
@@ -252,7 +252,7 @@
             this.okButton.UseStock = true;
             this.okButton.UseUnderline = true;
             this.okButton.Label = "gtk-new";
-            this.AddActionWidget(this.okButton, 0);
+            w21.Add(this.okButton);
             Gtk.ButtonBox.ButtonBoxChild w23 = ((Gtk.ButtonBox.ButtonBoxChild)(w21[this.okButton]));
             w23.Position = 1;
             w23.Expand = false;
Index: src/core/MonoDevelop.Ide/gtk-gui/gui.stetic
===================================================================
--- src/core/MonoDevelop.Ide/gtk-gui/gui.stetic	(revision 97933)
+++ src/core/MonoDevelop.Ide/gtk-gui/gui.stetic	(revision 112335)
@@ -5991,7 +5991,7 @@
             <property name="UseStock">True</property>
             <property name="Type">StockItem</property>
             <property name="StockId">gtk-new</property>
-            <property name="ResponseId">0</property>
+            <property name="ResponseId">-1</property>
             <property name="label">gtk-new</property>
           </widget>
           <packing>
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs	(revision 112335)
@@ -763,11 +763,14 @@
 		
 		public void CreateProjectFile (Project parentProject, string basePath, string selectedTemplateId)
 		{
-			using (NewFileDialog nfd = new NewFileDialog (parentProject, basePath)) {
+			NewFileDialog nfd = null;
+			try {
+				nfd = new NewFileDialog (parentProject, basePath);
 				if (selectedTemplateId != null)
 					nfd.SelectTemplate (selectedTemplateId);
 				nfd.Run ();
-				nfd.Dispose ();
+			} finally {
+				if (nfd != null) nfd.Destroy ();
 			}
 		}
 
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs	(revision 112335)
@@ -696,6 +696,17 @@
 					return pad;
 			return null;
 		}
+		
+		internal void ReorderDocuments (int oldPlacement, int newPlacement)
+		{
+			IViewContent content = workbench.ViewContentCollection[oldPlacement];
+			workbench.InternalViewContentCollection.RemoveAt (oldPlacement);
+			workbench.InternalViewContentCollection.Insert (newPlacement, content);
+			
+			Document doc = documents [oldPlacement];
+			documents.RemoveAt (oldPlacement);
+			documents.Insert (newPlacement, doc);
+		}
 	}
 	
 	class FileInformation
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs	(revision 112335)
@@ -251,12 +251,7 @@
 		
 		void OnTabsReordered (Widget widget, int oldPlacement, int newPlacement)
 		{
-			lock (workbench.ViewContentCollection) {
-				IViewContent content = workbench.ViewContentCollection[oldPlacement];
-				workbench.InternalViewContentCollection.RemoveAt (oldPlacement);
-				workbench.InternalViewContentCollection.Insert (newPlacement, content);
-				
-			}
+			IdeApp.Workbench.ReorderDocuments (oldPlacement, newPlacement);
 		}
 
 		void OnContextChanged (object o, EventArgs e)
Index: src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskService.cs
===================================================================
--- src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskService.cs	(revision 97933)
+++ src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskService.cs	(revision 112335)
@@ -203,7 +203,7 @@
 		{
 			for (int i = 0; i < tasks.Count; ++i) {
 				Task curTask = tasks[i];
-				if (Path.GetFullPath (curTask.FileName) == Path.GetFullPath (e.OldName)) {
+				if (!string.IsNullOrEmpty (curTask.FileName) && Path.GetFullPath (curTask.FileName) == Path.GetFullPath (e.OldName)) {
 					Remove (curTask);
 					curTask.FileName = Path.GetFullPath (e.NewName);
 					Add (curTask);
Index: src/core/MonoDevelop.Components/MonoDevelop.Components/FileSelector.cs
===================================================================
--- src/core/MonoDevelop.Components/MonoDevelop.Components/FileSelector.cs	(revision 97933)
+++ src/core/MonoDevelop.Components/MonoDevelop.Components/FileSelector.cs	(revision 112335)
@@ -97,12 +97,6 @@
 		{
 			PropertyService.Set (LastPathProperty, this.CurrentFolder);
 		}
-		
-		public override void Dispose ()
-		{
-			base.Dispose ();
-			Destroy ();
-		}
 	}
 }
 
Index: src/core/MonoDevelop.Components/MonoDevelop.Components/FileEntry.cs
===================================================================
--- src/core/MonoDevelop.Components/MonoDevelop.Components/FileEntry.cs	(revision 97933)
+++ src/core/MonoDevelop.Components/MonoDevelop.Components/FileEntry.cs	(revision 112335)
@@ -51,11 +51,11 @@
 			int response = fd.Run ();
 			
 			if (response == (int) ResponseType.Ok) {
-				fd.Hide ();
+				fd.Destroy ();
 				return fd.Filename;
 			}
 
-			fd.Hide ();			
+			fd.Destroy ();			
 
 			return null;
 		}
Index: src/core/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs
===================================================================
--- src/core/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs	(revision 97933)
+++ src/core/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs	(revision 112335)
@@ -390,11 +390,6 @@
 		public void ShowContextMenu (Gtk.Menu menu)
 		{
 			menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
-			menu.Hidden += delegate {
-				// Needed to make sure the menu entries are destroyed and
-				// can't handle accelerators
-				menu.Destroy ();
-			};
 		}
 		
 		public void ShowContextMenu (Gtk.Menu menu, object initialCommandTarget)
Index: src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs
===================================================================
--- src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs	(revision 97933)
+++ src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs	(revision 112335)
@@ -50,11 +50,12 @@
 		private void CaptureOutput ()
 		{
 			try {
-				string s;
+				char[] buffer = new char [1000];
 				if (OutputStreamChanged != null) {
-					while ((s = StandardOutput.ReadLine()) != null) {
+					int nr;
+					while ((nr = StandardOutput.Read (buffer, 0, buffer.Length)) > 0) {
 						if (OutputStreamChanged != null)
-							OutputStreamChanged (this, s);
+							OutputStreamChanged (this, new string (buffer, 0, nr));
 					}
 				}
 			} finally {
@@ -65,11 +66,12 @@
 		private void CaptureError ()
 		{
 			try {
-				string s;
+				char[] buffer = new char [1000];
 				if (ErrorStreamChanged != null) {
-					while ((s = StandardError.ReadLine()) != null) {
+					int nr;
+					while ((nr = StandardError.Read (buffer, 0, buffer.Length)) > 0) {
 						if (ErrorStreamChanged != null)
-							ErrorStreamChanged (this, s);
+							ErrorStreamChanged (this, new string (buffer, 0, nr));
 					}					
 				}
 			} finally {
Index: src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs
===================================================================
--- src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs	(revision 97933)
+++ src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs	(revision 112335)
@@ -357,7 +357,7 @@
 		
 		public void WriteOut (object sender, string s)
 		{
-			writer.WriteLine (s);
+			writer.Write (s);
 		}
 		
 		public static ProcessEventHandler GetWriteHandler (TextWriter tw)
openSUSE Build Service is sponsored by