11-22-2015 01:19 PM
Bob Breeding and I figured out one thing that might be causing the framework error on exit with the new Act! v17.2 HF1b hotfix. When Act! exits now it fires the UIClosing event two times. Most of us addon writers have cleanup routines that execute when the UIClosing event is fired. For example my routine will remove a button that I have added and remove a menu that I have added. When the UIClosing event fires for the second time my routine tries to remove the button and the menu again and when it does it gets an "Object not set to an instance of an object" error message because the button and menu item are already gone. Technically it hits the remove button routine before it attempts the remove menu routine and fails when attempting to remove the button for the second time. It is relatively easy to change my code to resolve this issue but the UIClosing event shouldn't be firing twice when Act! closes. I gave Bob a plugin that will demonstrate the problem and they are going to work on getting either a new hotfix or updating the current hotfix. Either Bob or I will update this thread when that issue is resolved.
11-23-2015 06:59 AM
To be more specific I found the error occurs in the New Act.UI.Core.CommandBarButton function. While in the process of shutting down ACTAPP.Explorer is not null but asking for a new CommandBarButton throws an error.
My code below was originally throwing the error back up to but since the UI ( ACT and/or IMPACT ) is null the error goes all the way through ACT causing it to crash.
The fix was to handle the error rather then throwing it. ( as seen in the Catch below)
Public Shared Sub AddMenuItem(ByVal urn As String, ByVal MenuText As String, ByVal Handler As Act.UI.CommandHandler, ByVal ACTAPP As Act.UI.ActApplication) Try '----------------------------------------------------- ' Check if the connected menus exists '----------------------------------------------------- If ACTAPP.Explorer.CommandBarCollection("Connected Menus") Is Nothing Then Return End If If (MenuItemExists(urn, ACTAPP) = True) Then RemoveMenuItem(urn, ACTAPP) End If Dim ParentMenu As Act.UI.Core.CommandBarControl ParentMenu = CType(ACTAPP.Explorer.CommandBarCollection("Connected Menus").ControlCollection(GetParentControlURN(urn)), Act.UI.Core.CommandBarControl) Dim NewMenu As Act.UI.Core.CommandBarButton NewMenu = New Act.UI.Core.CommandBarButton(MenuText, MenuText, Nothing, urn, Nothing, Nothing) NewMenu.DisplayStyle = Act.UI.Core.CommandBarControl.ItemDisplayStyle.TextOnly ACTAPP.RegisterCommand(urn, Handler, Act.UI.RegisterType.Shell) If ParentMenu.SubItems.Length = 0 Then ParentMenu.AddSubItem(NewMenu, 0) Else ParentMenu.AddSubItem(NewMenu, 1) End If Catch ex As Exception ' 220.127.116.11 ' We catch the error rather the THROW ' since this could be raised on ACT shutdown ' Causing ACT to crash while its shutting down LogError.Write(ex, "ACTAPPFunctions:AddMenuItem") ' Throw New Exception("ACTAPPFunctions:AddMenuItem", ex) End Try End Sub
Hope this also helps
-- Jim Durkin
11-23-2015 08:57 AM
I think that may be a different issue that the one that was causing my error. In your case it can't add the button because the actapp.explorer is mostly still there but is incapable of adding a button because something is missing. In my case the button was already gone and trying to remove it again caused the error. In my case it was probably poor coding because I made the assumption that the button was there and that the UIClosing event would only occur once. In my later code I check to see if the button exists before I attempt to remove it. There are all sorts of errors that could occur as a result of the UIClosing event firing twice because parts of Act! manage to shut down before the event fires for the second time. I'm not surprised that your code would fail as well but to tell the truth the UIClosing event handler seems like an odd time to be adding menu entries and buttons though! ;-)
11-23-2015 10:33 AM
11-23-2015 10:57 AM
Just messing with you Jim. The real issue is if they hadn't pulled the hotfix all of our customers who upgraded to the new hotfix would suddenly have their programs not shutting down properly. Which also might mean that Act! would be running in the background and consequently they wouldn't be able to restart Act! unless they terminated it manually or rebooted the system.