From: Date: October 30 2006 9:40pm Subject: Connector/NET commit: r442 - in trunk: . mysqlclient List-Archive: http://lists.mysql.com/commits/14580 X-Bug: 22882 Message-Id: <200610302040.k9UKeZBx031435@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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); + } + } + /// /// 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 @@ //------------------------------------------------------------------------------ // // 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 @@ } /// + /// Looks up a localized string similar to This category includes a series of counters for MySQL.. + /// + internal static string PerfMonCategoryHelp { + get { + return ResourceManager.GetString("PerfMonCategoryHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to .NET Data Provider for MySQL. + /// + internal static string PerfMonCategoryName { + get { + return ResourceManager.GetString("PerfMonCategoryName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of times a procedures metadata had to be queried from the server.. + /// + internal static string PerfMonHardProcHelp { + get { + return ResourceManager.GetString("PerfMonHardProcHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hard Procedure Queries. + /// + internal static string PerfMonHardProcName { + get { + return ResourceManager.GetString("PerfMonHardProcName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of times a procedures metadata was retrieved from the client-side cache.. + /// + internal static string PerfMonSoftProcHelp { + get { + return ResourceManager.GetString("PerfMonSoftProcHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Soft Procedure Queries. + /// + internal static string PerfMonSoftProcName { + get { + return ResourceManager.GetString("PerfMonSoftProcName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to same name are not supported.. /// 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 @@ There was an error parsing the foreign key definition. + + This category includes a series of counters for MySQL. + + + .NET Data Provider for MySQL + + + The number of times a procedures metadata had to be queried from the server. + + + Hard Procedure Queries + + + The number of times a procedures metadata was retrieved from the client-side cache. + + + Soft Procedure Queries + \ No newline at end of file