diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs index 74d51d9..50403bb 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs @@ -251,7 +251,10 @@ namespace Acacia.Stubs.OutlookWrappers public IExplorer GetActiveExplorer() { - return new ExplorerWrapper(_app.ActiveExplorer()); + NSOutlook.Explorer explorer = _app.ActiveExplorer(); + if (explorer == null) + return null; + return new ExplorerWrapper(explorer); } public IInspectors GetInspectors() diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/FolderRegistration.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/FolderRegistration.cs index ecb9175..a15262a 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/FolderRegistration.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/FolderRegistration.cs @@ -74,6 +74,8 @@ namespace Acacia.ZPush // TODO: cache folder id per store using (IStore store = folder.GetStore()) { + if (store == null) + return false; return folder.EntryID == store.GetDefaultFolderId(_folder); } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccounts.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccounts.cs index eebfabf..9b8f58c 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccounts.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushAccounts.cs @@ -137,6 +137,8 @@ namespace Acacia.ZPush public ZPushAccount GetAccount(IStore store) { + if (store == null) + return null; ZPushAccount value = null; _accountsByStoreId.TryGetValue(store.StoreID, out value); return value; diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs index 3801d7b..991116e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ZPushWatcher.cs @@ -52,15 +52,17 @@ namespace Acacia.ZPush Accounts = new ZPushAccounts(this, addIn); // Need to keep a link to keep receiving events + // Might be null when starting a compose window only _explorer = _addIn.GetActiveExplorer(); - _explorer.SelectionChange += Explorer_SelectionChange; + if (_explorer != null) + _explorer.SelectionChange += Explorer_SelectionChange; } protected override void DoRelease() { Accounts.Dispose(); Sync.Dispose(); - _explorer.Dispose(); + _explorer?.Dispose(); } ///