From 1ed8dd773b6e960055fa33795c54d4994d82cfdf Mon Sep 17 00:00:00 2001 From: Mike Williams-UK Date: Wed, 21 Aug 2024 15:48:34 +0000 Subject: [PATCH] Merged PR 683: V3.2.20 Release 16 - BugFix: 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules Related work items: #1154 --- src/Chem4Word.V3/Chem4WordV3.cs | 34 +++++++++++++- src/Chem4Word.V3/Data/Chem4Word-Versions.xml | 8 +--- src/Chem4Word.V3/Data/This-Version.xml | 2 +- src/Chem4Word.V3/Helpers/RegistryHelper.cs | 13 +++++- src/Chem4Word.V3/Properties/AssemblyInfo.cs | 4 +- src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs | 1 + .../Chem4Word.ACME/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Chem4Word.Core/Helpers/Constants.cs | 2 + .../Chem4Word.Core/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Chem4WordSetup/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../WiX.CustomAction/CustomAction.cs | 44 +++++++++++++++++- .../Properties/AssemblyInfo.cs | 4 +- src/Installer/WiXInstaller/Product.wxs | 4 +- src/Installer/WiXInstaller/Test.cmd | 10 ++-- .../Testing/Insert Test Messages.reg | Bin 0 -> 1158 bytes .../WiXInstaller/WiX-Installer.wixproj | 4 ++ src/Notes/Releases.txt | 2 +- .../Contracts/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../OoXmlV4/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- src/Scripts/Insert Test Messages.reg | Bin 0 -> 1158 bytes src/Scripts/Set-Assembly-Version.ps1 | 28 ++++++++++- .../Properties/AssemblyInfo.cs | 4 +- .../Wpf.UI.Sandbox/Properties/AssemblyInfo.cs | 4 +- src/UnitTests/Properties/AssemblyInfo.cs | 4 +- 36 files changed, 177 insertions(+), 63 deletions(-) create mode 100644 src/Installer/WiXInstaller/Testing/Insert Test Messages.reg create mode 100644 src/Scripts/Insert Test Messages.reg diff --git a/src/Chem4Word.V3/Chem4WordV3.cs b/src/Chem4Word.V3/Chem4WordV3.cs index 5f521e4c..52745d4e 100644 --- a/src/Chem4Word.V3/Chem4WordV3.cs +++ b/src/Chem4Word.V3/Chem4WordV3.cs @@ -29,6 +29,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; +using System.Timers; using System.Windows; using System.Windows.Forms; using System.Windows.Threading; @@ -85,6 +86,8 @@ public partial class Chem4WordV3 public LibraryOptions LibraryOptions; public TelemetryWriter Telemetry; + private System.Timers.Timer _timer; + public List Editors = new List(); public List Renderers = new List(); public List Searchers = new List(); @@ -332,6 +335,11 @@ private void PerformStartUpActions() try { + _timer = new System.Timers.Timer(1000); + _timer.Elapsed += OnTimerElapsed; + _timer.AutoReset = true; + _timer.Enabled = true; + SetButtonStates(ButtonState.NoDocument); LoadOptions(); @@ -421,6 +429,23 @@ private void PerformStartUpActions() } } + private void OnTimerElapsed(object sender, ElapsedEventArgs e) + { + if (Telemetry != null + && Helper != null + && !string.IsNullOrEmpty(Helper.IpAddress) + && !Helper.IpAddress.Equals("0.0.0.0") + && !Helper.IpAddress.Equals("0.0.0.0")) + { + RegistryHelper.SendSetupActions(); + RegistryHelper.SendUpdateActions(); + RegistryHelper.SendMsiActions(); + + _timer.Enabled = false; + _timer.Elapsed -= OnTimerElapsed; + } + } + public void LoadNamesFromLibrary() { var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod()?.Name}()"; @@ -931,7 +956,7 @@ public IChem4WordRenderer GetRendererPlugIn(string name) } } } - + if (plugin == null) { Telemetry.Write(module, "Warning", $"Could not find renderer plug in {name}"); @@ -1633,6 +1658,8 @@ private void HandleRightClick(Word.Selection selection) Telemetry.Write(module, "Exception", ex.ToString()); } + ClearChemistryContextMenus(); + if (selectedWords.Count > 0) { AddChemistryMenuPopup(selectedWords); @@ -1711,7 +1738,8 @@ private void ClearChemistryContextMenus() var popupControl = (CommandBarPopup)contextMenu.FindControl( MsoControlType.msoControlPopup, Type.Missing, ContextMenuTag, true, true); - if (popupControl != null) + if (popupControl != null + && popupControl.Caption.Equals(ContextMenuText)) { popupControl.Delete(true); } @@ -1853,6 +1881,8 @@ private void OnDocumentChange() DisableContentControlEvents(); EnableContentControlEvents(); + ClearChemistryContextMenus(); + SelectChemistry(document.Application.Selection); EvaluateChemistryAllowed(); diff --git a/src/Chem4Word.V3/Data/Chem4Word-Versions.xml b/src/Chem4Word.V3/Data/Chem4Word-Versions.xml index 23d98f1d..57f45ea9 100644 --- a/src/Chem4Word.V3/Data/Chem4Word-Versions.xml +++ b/src/Chem4Word.V3/Data/Chem4Word-Versions.xml @@ -5,10 +5,9 @@ 3.2.20 Release 16 false - 31-Aug-2024 + 21-Aug-2024 - ... - ... + BugFix: 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry If you like our product, please consider buying us a coffee at https://www.buymeacoffee.com/chem4word Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating @@ -24,9 +23,6 @@ UX: Prohibit import of binary files BugFix: User unable to hide Hydrogens in Renderer (seen in Word document) Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-30105) - Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry - If you like our product, please consider buying us a coffee at https://www.buymeacoffee.com/chem4word - Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating diff --git a/src/Chem4Word.V3/Data/This-Version.xml b/src/Chem4Word.V3/Data/This-Version.xml index 532c5d9d..d429393c 100644 --- a/src/Chem4Word.V3/Data/This-Version.xml +++ b/src/Chem4Word.V3/Data/This-Version.xml @@ -2,5 +2,5 @@ 3.2.20 Release 16 false - 31-Aug-2024 + 21-Aug-2024 \ No newline at end of file diff --git a/src/Chem4Word.V3/Helpers/RegistryHelper.cs b/src/Chem4Word.V3/Helpers/RegistryHelper.cs index c2d32ce9..8edcf900 100644 --- a/src/Chem4Word.V3/Helpers/RegistryHelper.cs +++ b/src/Chem4Word.V3/Helpers/RegistryHelper.cs @@ -85,6 +85,17 @@ public static void SendUpdateActions() } } + public static void SendMsiActions() + { + var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; + + var registryKey = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordMsiActionsRegistryKey, true); + if (registryKey != null) + { + SendValues(module, "Setup", registryKey); + } + } + public static void SendMessages() { var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; @@ -103,7 +114,7 @@ public static void SendExceptions() var registryKey = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordExceptionsRegistryKey, true); if (registryKey != null) { - SendValues(module, "Exceptions", registryKey); + SendValues(module, "Exception", registryKey); } } diff --git a/src/Chem4Word.V3/Properties/AssemblyInfo.cs b/src/Chem4Word.V3/Properties/AssemblyInfo.cs index 30cc22f3..025abffa 100644 --- a/src/Chem4Word.V3/Properties/AssemblyInfo.cs +++ b/src/Chem4Word.V3/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs b/src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs index b1b62c85..59d81c8e 100644 --- a/src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs +++ b/src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs @@ -618,6 +618,7 @@ private void AfterButtonChecks(RibbonButton button) { RegistryHelper.SendSetupActions(); RegistryHelper.SendUpdateActions(); + RegistryHelper.SendMsiActions(); RegistryHelper.SendMessages(); RegistryHelper.SendExceptions(); } diff --git a/src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs b/src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs index de813c20..074554e5 100644 --- a/src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs +++ b/src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Chemistry/Chem4Word.Libraries/Properties/AssemblyInfo.cs b/src/Chemistry/Chem4Word.Libraries/Properties/AssemblyInfo.cs index a2afe9f2..5ff18dd1 100644 --- a/src/Chemistry/Chem4Word.Libraries/Properties/AssemblyInfo.cs +++ b/src/Chemistry/Chem4Word.Libraries/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs b/src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs index b605b04e..7adb5998 100644 --- a/src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs +++ b/src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Chemistry/Chem4Word.WebServices/Properties/AssemblyInfo.cs b/src/Chemistry/Chem4Word.WebServices/Properties/AssemblyInfo.cs index fb001e58..2e18fd1e 100644 --- a/src/Chemistry/Chem4Word.WebServices/Properties/AssemblyInfo.cs +++ b/src/Chemistry/Chem4Word.WebServices/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Common/Chem4Word.Core/Helpers/Constants.cs b/src/Common/Chem4Word.Core/Helpers/Constants.cs index 5be43f0d..0e1fd21d 100644 --- a/src/Common/Chem4Word.Core/Helpers/Constants.cs +++ b/src/Common/Chem4Word.Core/Helpers/Constants.cs @@ -31,8 +31,10 @@ public static class Constants public const string RegistryValueNameAvailableVersion = "Available Version"; public const string RegistryValueNameAvailableIsBeta = "Available Is Beta"; public const string RegistryValueNameEndOfLife = "End of Life"; + public const string Chem4WordSetupRegistryKey = @"SOFTWARE\Chem4Word V3\Setup"; public const string Chem4WordUpdateRegistryKey = @"SOFTWARE\Chem4Word V3\Update"; + public const string Chem4WordMsiActionsRegistryKey = @"SOFTWARE\Chem4Word V3\MsiActions"; public const string Chem4WordMessagesRegistryKey = @"SOFTWARE\Chem4Word V3\Messages"; public const string Chem4WordExceptionsRegistryKey = @"SOFTWARE\Chem4Word V3\Exceptions"; public const string Chem4WordAzureSettingsRegistryKey = @"SOFTWARE\Chem4Word V3\AzureSettings"; diff --git a/src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs b/src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs index 06352994..04e9b07e 100644 --- a/src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs +++ b/src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs b/src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs index 9cbdfdb6..3a4111e2 100644 --- a/src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs +++ b/src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Installer/Chem4WordSetup/Properties/AssemblyInfo.cs b/src/Installer/Chem4WordSetup/Properties/AssemblyInfo.cs index 4315a824..bcc04f72 100644 --- a/src/Installer/Chem4WordSetup/Properties/AssemblyInfo.cs +++ b/src/Installer/Chem4WordSetup/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Installer/Chem4WordUpdater/Properties/AssemblyInfo.cs b/src/Installer/Chem4WordUpdater/Properties/AssemblyInfo.cs index caa33964..6a06fcaf 100644 --- a/src/Installer/Chem4WordUpdater/Properties/AssemblyInfo.cs +++ b/src/Installer/Chem4WordUpdater/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Installer/WiX.CustomAction/CustomAction.cs b/src/Installer/WiX.CustomAction/CustomAction.cs index 9f247a36..227643f1 100644 --- a/src/Installer/WiX.CustomAction/CustomAction.cs +++ b/src/Installer/WiX.CustomAction/CustomAction.cs @@ -1,4 +1,4 @@ -// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // Copyright (c) 2024, The .NET Foundation. // This software is released under the Apache License, Version 2.0. // The license and further copyright text can be found in the file LICENSE.md @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Security.AccessControl; @@ -88,6 +89,45 @@ public static ActionResult SetupChem4Word(Session session) return ActionResult.Success; } + [CustomAction] + public static ActionResult SetupChem4WordUser(Session session) + { + session.Log($"Begin {nameof(SetupChem4Word)}()"); + + session.Log($" Running as {Environment.UserName}"); + + try + { + const string baseKey = @"SOFTWARE\Chem4Word V3"; + + var key = Registry.CurrentUser.OpenSubKey(baseKey, true); + if (key == null) + { + key = Registry.CurrentUser.CreateSubKey(baseKey); + } + + string actionsKey = $@"{baseKey}\MsiActions"; + key = Registry.CurrentUser.OpenSubKey(actionsKey, true); + if (key == null) + { + key = key = Registry.CurrentUser.CreateSubKey(actionsKey); + } + + var versionNumber = "3.2.20.8999"; + + string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); + key.SetValue(timestamp, $"[-] V{versionNumber} - Installed"); + } + catch (Exception ex) + { + session.Log($"** Exception: {ex.Message} **"); + } + + session.Log($"End {nameof(SetupChem4Word)}()"); + + return ActionResult.Success; + } + private static void ModifyFolderPermissions(Session session) { session.Log($" Fixing SpecialFolder.CommonApplicationData {ProgramDataFolder}"); @@ -474,4 +514,4 @@ private static void RegisterChem4WordAddIn(Session session, RegistryKey rk, stri session.Log($" End {nameof(RegisterChem4WordAddIn)}()"); } } -} \ No newline at end of file +} diff --git a/src/Installer/WiX.CustomAction/Properties/AssemblyInfo.cs b/src/Installer/WiX.CustomAction/Properties/AssemblyInfo.cs index 843e4451..d6094b08 100644 --- a/src/Installer/WiX.CustomAction/Properties/AssemblyInfo.cs +++ b/src/Installer/WiX.CustomAction/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.2.20.9009")] -[assembly: AssemblyFileVersion("3.2.20.9009")] +[assembly: AssemblyVersion("3.2.20.8999")] +[assembly: AssemblyFileVersion("3.2.20.8999")] diff --git a/src/Installer/WiXInstaller/Product.wxs b/src/Installer/WiXInstaller/Product.wxs index f1c05871..6b48e78c 100644 --- a/src/Installer/WiXInstaller/Product.wxs +++ b/src/Installer/WiXInstaller/Product.wxs @@ -1,7 +1,7 @@  - + @@ -52,6 +52,7 @@ + @@ -60,6 +61,7 @@ NOT Installed NOT Installed NOT Installed + NOT Installed Installed diff --git a/src/Installer/WiXInstaller/Test.cmd b/src/Installer/WiXInstaller/Test.cmd index 8a345543..14cc51e1 100644 --- a/src/Installer/WiXInstaller/Test.cmd +++ b/src/Installer/WiXInstaller/Test.cmd @@ -1,16 +1,18 @@ dir bin\Setup\ rem pause +set release=Chem4Word-Setup.3.2.20.Release.16.msi + del setup.log del remove.log -msiexec /i bin\Setup\Chem4Word-Setup.3.1.16.Release.6.msi /l*v setup.log +msiexec /i bin\Setup\%release% /l*v setup.log -rem pause +pause -msiexec /uninstall bin\Setup\Chem4Word-Setup.3.1.16.Release.6.msi /l*v remove.log +msiexec /uninstall bin\Setup\%release% /l*v remove.log -rem pause +pause rem find "Property(" setup.log > properties.log rem search logs for "Calling custom action WiX.CustomAction" diff --git a/src/Installer/WiXInstaller/Testing/Insert Test Messages.reg b/src/Installer/WiXInstaller/Testing/Insert Test Messages.reg new file mode 100644 index 0000000000000000000000000000000000000000..c80e614b27998ed903584f0015222d690f45c2fe GIT binary patch literal 1158 zcmcJPT}#6-6o%hx!T(TtU$IRU6ucNRQN|QHyCL0>VTTsn2Wv(B^XijKv3?*@D2FsT z=OlgeG(CBJ8L7}hxt4lVDNl)Jx+PYs(pt|%x?~HyCBCO2`8C-Be}TWJ9qnS<+Hx(^ zsd}ur(zTA2^1cM`T$lK%288H6Q>lCi)eOEOysAk-y&ll zz7m`A?d_;JUsU7Um$l#dzACoKHh`$o1LxPA%KVe+Q>#s)6qcN`svv956xW#k`V;GF nZBq4JRd=YhrgipFR{>=9rube{0nsyV4STmtb&t*Xj=tUiSq-1~ literal 0 HcmV?d00001 diff --git a/src/Installer/WiXInstaller/WiX-Installer.wixproj b/src/Installer/WiXInstaller/WiX-Installer.wixproj index d048a905..ed5d9ff3 100644 --- a/src/Installer/WiXInstaller/WiX-Installer.wixproj +++ b/src/Installer/WiXInstaller/WiX-Installer.wixproj @@ -58,6 +58,7 @@ + @@ -69,6 +70,9 @@ INSTALLFOLDER + + +