From: Date: October 27 2006 10:31pm
Subject: Connector/NET commit: r437 - in trunk: . Installer mysqlclient
List-Archive: http://lists.mysql.com/commits/14503
X-Bug: 23245
Message-Id: <200610272031.k9RKVLRJ010060@bk-internal.mysql.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Added:
trunk/Installer/CustomAction.config
trunk/Installer/InstallUtilLib.dll
trunk/mysqlclient/Installer.cs
Removed:
trunk/Installer/MachineConfig.js
Modified:
trunk/CHANGES
trunk/Installer/Custom.wxs
trunk/Installer/main.wxs
trunk/Installer/sources.wxs
trunk/mysqlclient/MySql.Data.2005.csproj
Log:
Bug #23245 Connector Net 5.01 Beta Installer produces Antivirus Error Message
Fixed this bug by replacing JScript based custom action with an Installer derived class inside MySQLClient. We had to add a helper library (InstallUtilLib.dll) and CustomAction.config as well as make significant changes to main.wxs.
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/CHANGES 2006-10-27 20:31:18 UTC (rev 437)
@@ -4,6 +4,7 @@
----------
Bug #23268 System.FormatException when invoking procedure with ENUM input parameter
Bug #23538 Exception thrown when GetSchemaTable is called and "fields" is null.
+ Bug #23245 Connector Net 5.01 Beta Installer produces Antivirus Error Message
Other changes
-------------
Modified: trunk/Installer/Custom.wxs
===================================================================
--- trunk/Installer/Custom.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/Custom.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -47,14 +47,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
Added: trunk/Installer/CustomAction.config
===================================================================
--- trunk/Installer/CustomAction.config 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/CustomAction.config 2006-10-27 20:31:18 UTC (rev 437)
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Added: trunk/Installer/InstallUtilLib.dll
===================================================================
(Binary files differ)
Property changes on: trunk/Installer/InstallUtilLib.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/Installer/MachineConfig.js
===================================================================
--- trunk/Installer/MachineConfig.js 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/MachineConfig.js 2006-10-27 20:31:18 UTC (rev 437)
@@ -1,262 +0,0 @@
-// Launched during installation
-function InstallMachineConfig()
-{
- DoAllJob("Install");
-}
-
-// Launched during deinstalation
-function UninstallMachineConfig()
-{
- DoAllJob("Uninstall");
-}
-
-// Does all job
-function DoAllJob(action)
-{
- // Init log
- var log = InitLog();
- WriteLineToLog(log, "Initializing installation.");
- WriteLineToLog(log, "Action is " + action);
-
-
- // Get framework root
- var frameworkRoot = GetFrameworkRoot(log);
- if( frameworkRoot == null )
- {
- WriteLineToLog("Failed to get framework root!");
- return;
- }
- WriteLineToLog(log, "Framework root: " + frameworkRoot);
-
- // Get 2.0 path
- var machineConfig = GetMachineConfigPath(log, frameworkRoot);
- if( machineConfig == null )
- {
- WriteLineToLog("Failed to get machine.config path!");
- return;
- }
- WriteLineToLog(log, "machine.config path: " + machineConfig);
-
- // Perform main task
- MainOperation(log, machineConfig, action);
-
- // Close log
- CloseLog(log);
-}
-
-// Returns machine.config path
-function GetMachineConfigPath(log, root)
-{
- try
- {
- // Create fso
- var fso, f, fc, s;
- fso = new ActiveXObject("Scripting.FileSystemObject");
- if(fso == null)
- {
- WriteLineToLog(log, "Failed to get FSO!");
- return null;
- }
-
- // Get root information
- f = fso.GetFolder(root);
- if(fso == null)
- {
- WriteLineToLog(log, "Failed to get information about framework root!");
- return null;
- }
-
- // Enumerate subfolders
- fc = new Enumerator(f.SubFolders);
- if(fc == null)
- {
- WriteLineToLog(log, "Failed to enumerate framework root subfolders!");
- return null;
- }
-
- // Search for v2.0.... subfolder
- for (; !fc.atEnd(); fc.moveNext())
- {
- if( fc.item().Name.indexOf("v2.0.") == 0)
- {
- // Extract config name and check for existence
- var result = root + fc.item().Name + "\\CONFIG\\machine.config";
- if( fso.FileExists(result) )
- return result;
- else
- WriteLineToLog(log, "File " + result + " doesn't exists.");
- }
- }
-
- WriteLineToLog(log, "v2.0 subfolder not founded!");
- return null;
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to get framework root because of exception!");
- return null;
- }
-}
-
-// Returns .NET frameworks root directory
-function GetFrameworkRoot(log)
-{
- try
- {
- var WshShell = new ActiveXObject("WScript.Shell");
- if( WshShell == null )
- {
- WriteLineToLog(log, "Failed to create WScript.Shell!");
- return null;
- }
- WriteLineToLog("reading framework root from registry");
- return WshShell.RegRead ("HKLM\\Software\\Microsoft\\.NETFramework\\InstallRoot");
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to get framework root because of exception!");
- return null;
- }
-}
-
-// Initializes log file on disk C
-function InitLog()
-{
- try
- {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- return fso.CreateTextFile("c:\\MySql.Data.log", true);
- }
- catch(e)
- {
- return null;
- }
-}
-
-// Writes text to log
-function WriteToLog(log, line)
-{
- try
- {
- if( log != null )
- log.Write(line);
- }
- catch(e)
- {
- }
-}
-
-// Writes line to log
-function WriteLineToLog(log, line)
-{
- try
- {
- if( log != null )
- log.WriteLine(line);
- }
- catch(e)
- {
- }
-}
-
-// Closes log file on disk C
-function CloseLog(log)
-{
- try
- {
- if( log != null )
- log.Close();
- }
- catch(e)
- {
- return null;
- }
-}
-
-// Performs main operation - alters machine.config
-function MainOperation(log, machineConfigPath, action)
-{
- var invariantName = "MySql.Data.MySqlClient";
-
- try
- {
- // Create DOM object
- var config = new ActiveXObject("Msxml2.DOMDocument");
- if( config == null )
- {
- WriteLineToLog(log, "Failed to create XML document!");
- return;
- }
- WriteLineToLog(log, "XML document created.");
-
- // Load machine config
- config.load(machineConfigPath);
- WriteLineToLog(log, "XML document loaded.");
-
- // Locate list of factpries
- var factoriesList = config.getElementsByTagName("DbProviderFactories");
- if( factoriesList == null || factoriesList.length <= 0 && factoriesList[0] == null )
- {
- WriteLineToLog(log, "Factories list is empty!");
- return;
- }
- WriteLineToLog(log, "Factories read.");
-
- // Modify list if it is founded
- var existEntry = GetExistsEntry(factoriesList[0], invariantName);
- WriteLineToLog(log, "Search for existed entry completed.");
-
- // Uninstall if installed
- if( action == "Uninstall" && existEntry != null )
- {
- WriteLineToLog(log, "Removing exists entry...");
- factoriesList[0].removeChild(existEntry);
- WriteLineToLog(log, "Existing entry removed.");
- }
-
- // Install if not installed
- if( action == "Install" && existEntry == null )
- {
- WriteLineToLog(log, "Creating new entry...");
- var newEntry = config.createElement("add");
- if(newEntry == null)
- {
- WriteLineToLog(log, "Factories to create new entry!");
- return;
- }
- WriteLineToLog(log, "New entry created.");
-
- WriteLineToLog(log, "Filling attributes...");
- newEntry.setAttribute("name", "MySQL Data Provider");
- newEntry.setAttribute("invariant", invariantName);
- newEntry.setAttribute("description", ".Net Framework Data Provider for MySQL");
- newEntry.setAttribute("type", "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data");
- WriteLineToLog(log, "Attributes are filled.");
-
- WriteLineToLog(log, "Appending entry...");
- factoriesList[0].appendChild(newEntry);
- WriteLineToLog(log, "New entry appended.");
- }
-
- // Save changes
- WriteLineToLog(log, "Saving changes...");
- config.save(machineConfigPath);
- WriteLineToLog(log, "machine.config succesfully saved.");
-
- }
- catch(e)
- {
- WriteLineToLog(log, "Failed to perform main task because of exception!");
- }
-}
-
-// Searches for existing provider entry
-function GetExistsEntry(factoriesList, invariantName)
-{
- for(i = 0; i < factoriesList.childNodes.length; i++ )
- {
- if( factoriesList.childNodes[i].getAttribute("invariant") == invariantName )
- return factoriesList.childNodes[i];
- }
- return null;
-}
\ No newline at end of file
Modified: trunk/Installer/main.wxs
===================================================================
--- trunk/Installer/main.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/main.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -51,6 +51,7 @@
+
@@ -115,17 +116,20 @@
+
+
+
+
+
+
-
-
-
-
+
+ NOT Installed
+ NOT Installed
-
- NOT Installed
- Installed
- (&Complete<>2) AND (!Complete=3)
-
+ Installed
+ Installed
+
Modified: trunk/Installer/sources.wxs
===================================================================
--- trunk/Installer/sources.wxs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/Installer/sources.wxs 2006-10-27 20:31:18 UTC (rev 437)
@@ -122,7 +122,6 @@
-
@@ -158,9 +157,9 @@
-
-
-
+
+
+
Added: trunk/mysqlclient/Installer.cs
===================================================================
--- trunk/mysqlclient/Installer.cs 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/mysqlclient/Installer.cs 2006-10-27 20:31:18 UTC (rev 437)
@@ -0,0 +1,108 @@
+using System.Configuration.Install;
+using System.ComponentModel;
+using System.Reflection;
+using System;
+using System.Windows.Forms;
+using Microsoft.Win32;
+using System.Xml;
+using System.IO;
+
+namespace MySql.Data.MySqlClient
+{
+ ///
+ /// We are adding a custom installer class to our assembly so our installer
+ /// can make proper changes to the machine.config file.
+ ///
+ [RunInstaller(true)]
+ public class CustomInstaller : Installer
+ {
+ ///
+ /// We override Install so we can add our assembly to the proper
+ /// machine.config files.
+ ///
+ ///
+ public override void Install(System.Collections.IDictionary stateSaver)
+ {
+ base.Install(stateSaver);
+ object installRoot = Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
+ "InstallRoot", null);
+ if (installRoot == null)
+ throw new Exception("Unable to retrieve install root for .NET framework");
+ string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
+ installRoot);
+
+ // now read the config file into memory
+ StreamReader sr = new StreamReader(configPath);
+ string configXML = sr.ReadToEnd();
+ sr.Close();
+
+ // 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", "");
+
+ // add the proper attributes
+ newNode.SetAttribute("name", "MySQL Data Provider");
+ newNode.SetAttribute("invariant", "MySql.Data.MySqlClient");
+ newNode.SetAttribute("description", ".Net Framework Data Provider for MySQL");
+
+ // add the type attribute by reflecting on the executing assembly
+ Assembly a = Assembly.GetExecutingAssembly();
+ newNode.SetAttribute("type", a.FullName);
+
+ XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories");
+ 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;
+ doc.Save(writer);
+ }
+
+ ///
+ /// We override Uninstall so we can remove out assembly from the
+ /// machine.config files.
+ ///
+ ///
+ public override void Uninstall(System.Collections.IDictionary savedState)
+ {
+ base.Uninstall(savedState);
+
+ object installRoot = Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\",
+ "InstallRoot", null);
+ if (installRoot == null)
+ throw new Exception("Unable to retrieve install root for .NET framework");
+ string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config",
+ installRoot);
+
+ // now read the config file into memory
+ StreamReader sr = new StreamReader(configPath);
+ string configXML = sr.ReadToEnd();
+ sr.Close();
+
+ // load the XML into the XmlDocument
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(configXML);
+
+ XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories");
+ foreach (XmlNode node in nodes[0].ChildNodes)
+ {
+ string name = node.Attributes["name"].Value;
+ if (name == "MySQL Data Provider")
+ {
+ nodes[0].RemoveChild(node);
+ break;
+ }
+ }
+
+ // Save the document to a file and auto-indent the output.
+ XmlTextWriter writer = new XmlTextWriter(configPath, null);
+ writer.Formatting = Formatting.Indented;
+ doc.Save(writer);
+ }
+ }
+}
Modified: trunk/mysqlclient/MySql.Data.2005.csproj
===================================================================
--- trunk/mysqlclient/MySql.Data.2005.csproj 2006-10-25 21:09:00 UTC (rev 436)
+++ trunk/mysqlclient/MySql.Data.2005.csproj 2006-10-27 20:31:18 UTC (rev 437)
@@ -11,8 +11,7 @@
MySql.Data
-
-
+ cnet.snk
JScript
Grid
IE50
@@ -91,13 +90,10 @@
GlobalSuppressions.cs
-
- False
- ..\ICSharpCode.SharpZipLib.dll
-
System
+
System.Data
@@ -116,6 +112,7 @@
+
@@ -143,6 +140,9 @@
+
+ Component
+