PC Review


Reply
Thread Tools Rate Thread

Application.ActiveInspector().CurrentItem Returns Wrong(Old) Value

 
 
Deepak N
Guest
Posts: n/a
 
      27th May 2009
I have outlook plugin in which OnLoad of Ribbon on contact form(custom form),I access Application.ActiveInspector().CurrentItem as ContactItem.

When I open a contact
*First time Application.ActiveInspector().CurrentItem gives correct value.
*Then I change First Name of this contact in Exchange server through code.
*Then i synchronize Outlook with exchange server and open the form, it displays old value of the contact. If try to edit and save it says contact being edited by other user or program

It is not Sync issue SINCE It displays the new value in the Contact's Business card view!!..
Submitted using http://www.outlookforums.com
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      27th May 2009
It sounds like you haven't released all object references to that original
object. Make sure you do that. Using managed code you might also have to
call Marshal.ReleaseComObject() on the object as well as GC.Collect().

In addition, make sure you aren't creating implicit object variables that
you cannot release. That happens when you use multiple dot operators such as
this:

explorer.Selection.Count

That creates an implicit Selection object that you can't release. The better
way is to do something like this:

Outlook.Selection selection = explorer.Selection;
int count = selection.Count;

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Deepak N" <endeep123[at]gmail[dot]com> wrote in message
news:%23dYEo%(E-Mail Removed)...
>I have outlook plugin in which OnLoad of Ribbon on contact form(custom
>form),I access Application.ActiveInspector().CurrentItem as ContactItem.
>
> When I open a contact
> *First time Application.ActiveInspector().CurrentItem gives correct value.
> *Then I change First Name of this contact in Exchange server through code.
> *Then i synchronize Outlook with exchange server and open the form, it
> displays old value of the contact. If try to edit and save it says contact
> being edited by other user or program
>
> It is not Sync issue SINCE It displays the new value in the Contact's
> Business card view!!.. Submitted using http://www.outlookforums.com


 
Reply With Quote
 
Deepak N
Guest
Posts: n/a
 
      7th Jun 2009
Thanks for reply.
Is it necessary release a COM Object, if a COM object is passed as parameter to a method.

Ex:
PrintName(ContactItemClass contact)
{
Console.WriteLine(contact.FirstName);
//Is it necessary to call Marshal.ReleaseComObject(contact) here
}.
Submitted using http://www.outlookforums.com
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      8th Jun 2009
That depends on whether or not you intend to use any references to that item
again. If you call Marshal.ReleaseComObject() on it that will release the
item's RCW and unless you re-instantiate another object on that item any
further references to it will return an exception.

At some point the object reference should be released, but when depends on
any further need for it.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Deepak N" <endeep123[at]gmail[dot]com> wrote in message
news:%(E-Mail Removed)...
> Thanks for reply.
> Is it necessary release a COM Object, if a COM object is passed as
> parameter to a method.
>
> Ex: PrintName(ContactItemClass contact)
> {
> Console.WriteLine(contact.FirstName);
> //Is it necessary to call Marshal.ReleaseComObject(contact) here
> }. Submitted using http://www.outlookforums.com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set background image for ActiveInspector.CurrentItem? Burma Jones Microsoft Outlook Form Programming 1 20th Feb 2006 07:13 AM
How to set background image for ActiveInspector.CurrentItem? Burma Jones Microsoft Outlook VBA Programming 1 20th Feb 2006 07:13 AM
Application.ActiveInspector.CurrentItem not set? Simon Shaw Microsoft Outlook VBA Programming 2 3rd Sep 2004 06:20 PM
ActiveInspector method returns wrong window when MS-Word is used as email editor Dattatraya Shewale Microsoft Outlook Program Addins 5 9th Jun 2004 05:08 PM
ActiveInspector method returns wrong window when MS-Word is used as email editor M Ali Microsoft Outlook Form Programming 0 8th Jun 2004 06:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:42 AM.