Modified:
trunk/CHANGES
trunk/mysqlclient/Installer.cs
Log:
Fixed problem in installer.cs where the information written to machine.config was wrong
and therefore prevented use of DbProviderFactory.GetFactory.
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-10-30 21:54:53 UTC (rev 444)
+++ trunk/CHANGES 2006-10-31 17:29:50 UTC (rev 445)
@@ -19,6 +19,8 @@
(A similar suggestion came in from a user)
Added 'Ignore Prepare' connection string option for disabling prepared
statements application-wide
+ Added Installer class to provide custom install type procedures such as modifying
+ machine.config
Version 5.0.1 (Beta)
Modified: trunk/mysqlclient/Installer.cs
===================================================================
--- trunk/mysqlclient/Installer.cs 2006-10-30 21:54:53 UTC (rev 444)
+++ trunk/mysqlclient/Installer.cs 2006-10-31 17:29:50 UTC (rev 445)
@@ -37,8 +37,21 @@
"InstallRoot", null);
if (installRoot == null)
throw new Exception("Unable to retrieve install root for .NET framework");
+
+ AddProviderToMachineConfigInDir(installRoot.ToString());
+
+ string installRoot64 = installRoot.ToString();
+ installRoot64 = installRoot64.Substring(0, installRoot64.Length - 1);
+ installRoot64 = string.Format("{0}64{1}", installRoot64,
+ Path.DirectorySeparatorChar);
+ if (Directory.Exists(installRoot64))
+ AddProviderToMachineConfigInDir(installRoot64);
+ }
+
+ private void AddProviderToMachineConfigInDir(string path)
+ {
string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
- installRoot);
+ path);
// now read the config file into memory
StreamReader sr = new StreamReader(configPath);
@@ -59,11 +72,25 @@
// add the type attribute by reflecting on the executing assembly
Assembly a = Assembly.GetExecutingAssembly();
- newNode.SetAttribute("type", a.FullName);
+ string type = String.Format("MySql.Data.MySqlClient.MySqlClientFactory, {0}",
a.FullName);
+ newNode.SetAttribute("type", type);
XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories");
- nodes[0].AppendChild(newNode);
+ bool alreadyThere = false;
+ foreach (XmlNode node in nodes[0].ChildNodes)
+ {
+ string typeValue = node.Attributes["type"].Value;
+ if (typeValue == type)
+ {
+ alreadyThere = true;
+ break;
+ }
+ }
+
+ if (! alreadyThere)
+ nodes[0].AppendChild(newNode);
+
// Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter(configPath, null);
writer.Formatting = Formatting.Indented;
@@ -106,8 +133,22 @@
"InstallRoot", null);
if (installRoot == null)
throw new Exception("Unable to retrieve install root for .NET framework");
+
+
+ RemoveProviderFromMachineConfigInDir(installRoot.ToString());
+
+ string installRoot64 = installRoot.ToString();
+ installRoot64 = installRoot64.Substring(0, installRoot64.Length - 1);
+ installRoot64 = string.Format("{0}64{1}", installRoot64,
+ Path.DirectorySeparatorChar);
+ if (Directory.Exists(installRoot64))
+ RemoveProviderFromMachineConfigInDir(installRoot64);
+ }
+
+ private void RemoveProviderFromMachineConfigInDir(string path)
+ {
string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
- installRoot);
+ path);
// now read the config file into memory
StreamReader sr = new StreamReader(configPath);
| Thread |
|---|
| • Connector/NET commit: r445 - in trunk: . mysqlclient | rburnett | 31 Oct |