List:Commits« Previous MessageNext Message »
From:rburnett Date:October 30 2006 8:40pm
Subject:Connector/NET commit: r442 - in trunk: . mysqlclient
View as plain text  
Modified:
   trunk/CHANGES
   trunk/mysqlclient/Installer.cs
   trunk/mysqlclient/PerformanceMonitor.cs
   trunk/mysqlclient/Resources.Designer.cs
   trunk/mysqlclient/Resources.resx
Log:
Bug #22882 Registry key 'Global' access denied 

This bug was fixed by adding code to the installer class to create the perf mon categories and counters during installation.  Added strings to the resources file for the category names and helps.

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2006-10-30 16:50:34 UTC (rev 441)
+++ trunk/CHANGES	2006-10-30 20:40:34 UTC (rev 442)
@@ -6,6 +6,7 @@
     Bug #23538 Exception thrown when GetSchemaTable is called and "fields" is null. 
     Bug #23245 Connector Net 5.01 Beta Installer produces Antivirus Error Message 
     Bug #23758 Unable to connect to any server - IPv6 related 
+    Bug #22882 Registry key 'Global' access denied 
     
     Other changes
     -------------

Modified: trunk/mysqlclient/Installer.cs
===================================================================
--- trunk/mysqlclient/Installer.cs	2006-10-30 16:50:34 UTC (rev 441)
+++ trunk/mysqlclient/Installer.cs	2006-10-30 20:40:34 UTC (rev 442)
@@ -6,6 +6,7 @@
 using Microsoft.Win32;
 using System.Xml;
 using System.IO;
+using System.Diagnostics;
 
 namespace MySql.Data.MySqlClient
 {
@@ -24,6 +25,13 @@
 		public override void Install(System.Collections.IDictionary stateSaver)
 		{
 			base.Install(stateSaver);
+
+			AddProviderToMachineConfig();
+			InstallPerfMonItems();
+		}
+
+		private void AddProviderToMachineConfig()
+		{
 			object installRoot = Registry.GetValue(
 				@"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
 				"InstallRoot", null);
@@ -40,7 +48,7 @@
 			// load the XML into the XmlDocument
 			XmlDocument doc = new XmlDocument();
 			doc.LoadXml(configXML);
- 
+
 			// create our new node
 			XmlElement newNode = (XmlElement)doc.CreateNode(XmlNodeType.Element, "add", "");
 
@@ -62,6 +70,22 @@
 			doc.Save(writer);
 		}
 
+		private void InstallPerfMonItems()
+		{
+			string categoryName = Resources.PerfMonCategoryName;
+
+			if (!PerformanceCounterCategory.Exists(categoryName))
+			{
+				CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
+				ccdc.Add(new CounterCreationData(Resources.PerfMonHardProcName,
+					Resources.PerfMonHardProcHelp, PerformanceCounterType.NumberOfItems32));
+				ccdc.Add(new CounterCreationData(Resources.PerfMonSoftProcName,
+					Resources.PerfMonSoftProcHelp, PerformanceCounterType.NumberOfItems32));
+				PerformanceCounterCategory.Create(categoryName, Resources.PerfMonCategoryHelp,
+					PerformanceCounterCategoryType.SingleInstance, ccdc);
+			}
+		}
+
 		/// <summary>
 		/// We override Uninstall so we can remove out assembly from the
 		/// machine.config files.
@@ -71,6 +95,12 @@
 		{
 			base.Uninstall(savedState);
 
+			RemoveProviderFromMachineConfig();
+			RemovePerfMonItems();
+		}
+
+		private void RemoveProviderFromMachineConfig()
+		{
 			object installRoot = Registry.GetValue(
 				@"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
 				"InstallRoot", null);
@@ -104,5 +134,15 @@
 			writer.Formatting = Formatting.Indented;
 			doc.Save(writer);
 		}
+
+		private void RemovePerfMonItems()
+		{
+			string categoryName = Resources.PerfMonCategoryName;
+
+			// TODO: add code to inspect registry and make sure no other connector/net 5.x
+			// installs are present.
+			if (PerformanceCounterCategory.Exists(categoryName))
+				PerformanceCounterCategory.Delete(categoryName);
+		}
 	}
 }

Modified: trunk/mysqlclient/PerformanceMonitor.cs
===================================================================
--- trunk/mysqlclient/PerformanceMonitor.cs	2006-10-30 16:50:34 UTC (rev 441)
+++ trunk/mysqlclient/PerformanceMonitor.cs	2006-10-30 20:40:34 UTC (rev 442)
@@ -20,52 +20,42 @@
 
 using System;
 using System.Diagnostics;
+using System.Security.Permissions;
 
 
 namespace MySql.Data.MySqlClient
 {
-    class PerformanceMonitor
-    {
-        private MySqlConnection connection;
-        private static PerformanceCounter procedureHardQueries;
-        private static PerformanceCounter procedureSoftQueries;
-        private static string categoryName;
+	class PerformanceMonitor
+	{
+		private MySqlConnection connection;
+		private static PerformanceCounter procedureHardQueries;
+		private static PerformanceCounter procedureSoftQueries;
 
-        public PerformanceMonitor(MySqlConnection connection)
-        {
-            this.connection = connection;
+		public PerformanceMonitor(MySqlConnection connection)
+		{
+			this.connection = connection;
 
-            if (categoryName == null)
-            {
-                categoryName = ".NET Data Provider for MySQL";
-            }
+			string categoryName = Resources.PerfMonCategoryName;
 
-            if (connection.Settings.UsePerformanceMonitor && procedureHardQueries == null)
-            {
-                if (PerformanceCounterCategory.Exists(categoryName))
-                {
-                    if (PerformanceCounterCategory.CounterExists("HardProcedureQueries",
-                        categoryName))
-                        procedureHardQueries = new PerformanceCounter(categoryName,
-                            "HardProcedureQueries", false);
-                    if (PerformanceCounterCategory.CounterExists("SoftProcedureQueries",
-                        categoryName))
-                        procedureSoftQueries = new PerformanceCounter(categoryName,
-                            "SoftProcedureQueries", false);
-                }
-            }
-        }
+			if (connection.Settings.UsePerformanceMonitor && procedureHardQueries == null)
+			{
+				procedureHardQueries = new PerformanceCounter(categoryName,
+					 "HardProcedureQueries", false);
+				procedureSoftQueries = new PerformanceCounter(categoryName,
+					 "SoftProcedureQueries", false);
+			}
+		}
 
-        public void AddHardProcedureQuery()
-        {
-            if (!connection.Settings.UsePerformanceMonitor) return;
-            procedureHardQueries.Increment();
-        }
+		public void AddHardProcedureQuery()
+		{
+			if (!connection.Settings.UsePerformanceMonitor) return;
+			procedureHardQueries.Increment();
+		}
 
-        public void AddSoftProcedureQuery()
-        {
-            if (!connection.Settings.UsePerformanceMonitor) return;
-            procedureSoftQueries.Increment();
-        }
-    }
+		public void AddSoftProcedureQuery()
+		{
+			if (!connection.Settings.UsePerformanceMonitor) return;
+			procedureSoftQueries.Increment();
+		}
+	}
 }

Modified: trunk/mysqlclient/Resources.Designer.cs
===================================================================
--- trunk/mysqlclient/Resources.Designer.cs	2006-10-30 16:50:34 UTC (rev 441)
+++ trunk/mysqlclient/Resources.Designer.cs	2006-10-30 20:40:34 UTC (rev 442)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.42
+//     Runtime Version:2.0.50727.308
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -412,6 +412,60 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to This category includes a series of counters for MySQL..
+        /// </summary>
+        internal static string PerfMonCategoryHelp {
+            get {
+                return ResourceManager.GetString("PerfMonCategoryHelp", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to .NET Data Provider for MySQL.
+        /// </summary>
+        internal static string PerfMonCategoryName {
+            get {
+                return ResourceManager.GetString("PerfMonCategoryName", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to The number of times a procedures metadata had to be queried from the server..
+        /// </summary>
+        internal static string PerfMonHardProcHelp {
+            get {
+                return ResourceManager.GetString("PerfMonHardProcHelp", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Hard Procedure Queries.
+        /// </summary>
+        internal static string PerfMonHardProcName {
+            get {
+                return ResourceManager.GetString("PerfMonHardProcName", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to The number of times a procedures metadata was retrieved from the client-side cache..
+        /// </summary>
+        internal static string PerfMonSoftProcHelp {
+            get {
+                return ResourceManager.GetString("PerfMonSoftProcHelp", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Soft Procedure Queries.
+        /// </summary>
+        internal static string PerfMonSoftProcName {
+            get {
+                return ResourceManager.GetString("PerfMonSoftProcName", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to same name are not supported..
         /// </summary>
         internal static string ProcAndFuncSameName {

Modified: trunk/mysqlclient/Resources.resx
===================================================================
--- trunk/mysqlclient/Resources.resx	2006-10-30 16:50:34 UTC (rev 441)
+++ trunk/mysqlclient/Resources.resx	2006-10-30 20:40:34 UTC (rev 442)
@@ -276,4 +276,22 @@
   <data name="UnableToParseFK" xml:space="preserve">
     <value>There was an error parsing the foreign key definition.</value>
   </data>
+  <data name="PerfMonCategoryHelp" xml:space="preserve">
+    <value>This category includes a series of counters for MySQL.</value>
+  </data>
+  <data name="PerfMonCategoryName" xml:space="preserve">
+    <value>.NET Data Provider for MySQL</value>
+  </data>
+  <data name="PerfMonHardProcHelp" xml:space="preserve">
+    <value>The number of times a procedures metadata had to be queried from the server.</value>
+  </data>
+  <data name="PerfMonHardProcName" xml:space="preserve">
+    <value>Hard Procedure Queries</value>
+  </data>
+  <data name="PerfMonSoftProcHelp" xml:space="preserve">
+    <value>The number of times a procedures metadata was retrieved from the client-side cache.</value>
+  </data>
+  <data name="PerfMonSoftProcName" xml:space="preserve">
+    <value>Soft Procedure Queries</value>
+  </data>
 </root>
\ No newline at end of file

Thread
Connector/NET commit: r442 - in trunk: . mysqlclientrburnett30 Oct