keni zhou
Guest
|
Dear Sir,
We have encountered the following exception when handle the "ADXSelectionChange" event in some scenario:
at Microsoft.Office.Interop.Outlook._Explorer.get_Selection()
at CMMP.Mail.Outlook.Globals.GetExplorerSelection() in D:\VS2017\source\repos\CMMP.Mail\CMMP.Mail.Outlook\Globals.cs:line 213
2019-07-11 09:25:58.6720 WARN red
I would like to know how can I to check if the "explorer" is available? or just to catch the exception?
Thanks,
Keni Zhou. |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Keni,
In what scenario do you get this exception? Could you please provide some code for us to see what you do? You can send it to the support email address; see {Add-in Express installation folder}\readme.txt; please make sure your email contains a link to this topic.
What Add-in Express build do you use? Does the issue persist if you turn off all other COM add-ins?
Andrei Smolin
Add-in Express Team Leader |
|
keni zhou
Guest
|
Dear Andrei,
I have a Outlook Region on the explorer and subscribe its "SelectionChange" event.
For example: I delegated UserA's Inbox to UserB's, then Open userB's inbox folder in UserA's Outlook.
private void MailHeader_ADXSelectionChange()
{
var explorer = Globals.CurrentExplorer;
Selection explorerSelection = null;
try
{
red
}
catch (System.Exception ex)
{
ExceptionHandler.SupressException(ex, "the selection object of explorer is not avaliable at this moment.");
}
if (explorerSelection == null)
{
return;
}
using (var selection = explorerSelection.WithComCleanup())
{
if (selection.Resource.Count > 0)
{
object selectedItem = selection.Resource[1];
currentMailItem = selectedItem as MailItem;
if (currentMailItem == null)
{
selectedItem.ReleaseComObject();
Hide();
}
else
{
Clean();
Reset(currentMailItem);
Show();
}
}
else
{
Hide();
}
}
}
Thanks! |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Keni,
Try to use this.ExplorerObj as Outlook.Explorer instead of Globals.CurrentExplorer. That property returns an Outlook.Explorer object managed by the form itself; you don't need to release that Explorer object.
Also, Explorer.Selection may produce an exception when in certain folders such as RSS Subscriptions. The complete list of such folders depends on the Outlook version used. Make sure you handle this exception.
Andrei Smolin
Add-in Express Team Leader |
|