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

Status
Not open for further replies.
D

Deepak N

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!!..
 
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;

"Deepak N" <endeep123[at]gmail[dot]com> wrote in message

news:%23dYEo%23p3JHA.4632@TK2MSFTNGP02.phx.gbl...
> 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!!..
 
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

}.
 
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.

"Deepak N" <endeep123[at]gmail[dot]com> wrote in message

news:%23RHscc45JHA.3860@TK2MSFTNGP05.phx.gbl...
> 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
> }.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
D Application.ActiveInspector() is Null on Ribbon Load Outlook VBA and Custom Forms 1
bmtjedi Set objApp = Application Not Working in O365-32bit Using Outlook 1
avant-guvnor Outlook.Application now produces error Outlook VBA and Custom Forms 5
C Custom Application Form send Email to Another User Using Outlook 1
N Select Existing BCM Business Contact in C# application Using Outlook 0
S Using "start application" rule action Using Outlook 2
smokiibear windows security mail application not accepting username and password Using Outlook 0
Y VBA - Application Filedialog Hidden Behind Outlook Using Outlook 0
T Synchronize outlook appointments through web application. Using Outlook 1
O Outlook 2010 Stops Working When Accounting Application Tries To Send eMail Using Outlook 4
C MAPI to access a 64 bit Outlook from a 32 bit application; or access via ODBC Using Outlook 0
K Handling application.quit event Outlook VBA and Custom Forms 8
M VSTO C#: How do I declare an application scope variable? Outlook VBA and Custom Forms 2
E Turn application visibility off Outlook VBA and Custom Forms 2
T Run application from cmd button Outlook VBA and Custom Forms 5
D Outlook 2007 Will Not Send Mail From C# Application Outlook VBA and Custom Forms 7
P Supporting threads in Outlook VBA application Outlook VBA and Custom Forms 1
R vba instantiated internetExplorer.application differs from user la Outlook VBA and Custom Forms 1
K How to disconnect Application.COMAddIns.Item().Object? Outlook VBA and Custom Forms 4
D outlook.exe application error - breakpoint has been reached. fix? BCM (Business Contact Manager) 1
P Drag and Drop mails from Outlook to Clarion6 Application Outlook VBA and Custom Forms 5
J Office application does not match advisory. Why? BCM (Business Contact Manager) 3
L RE: BCM Office Application Issue BCM (Business Contact Manager) 1
R Can calendar be displayed in another Office application? Outlook VBA and Custom Forms 1
P accessing custom task pane with Outlook ActiveInspector Using Outlook 1
Z Inspector.CurrentItem causes Shared Calendar Issue Outlook VBA and Custom Forms 5

Similar threads

Back
Top