|
Daniel Rail
Posts: 14
Joined: 2008-10-03
|
Hi,
I'm currently using Add-In-Express for Office and .Net 2010, with VS 2008 and .Net 3.5 SP1.
I'm trying to develop a data update notification between applications(stand-alone applications and Outlook add-ins on the network).
I'm trying to implement a WCF callback in my Outlook add-in, but the WCF callback doesn't trigger. And I know that it can connect to the WCF service, because it can send out the data update notification and that the stand-alone application is receiving it, via the WCF callback.
I'm just wondering if there is something that I'm missing for the WCF callback to work in the Outlook add-in. If someone already implemented WCF callbacks in an Outlook add-in, any help would be appreciated. |
|
Posted 22 Jul, 2010 15:34:32
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
Hi Daniel,
There's no such sample available. Talking about principles, it looks more correct to communicate with the service in a standalone application and to let the application to talk to the add-in via the following code path:
OutlookApp.COMAddins.Item(strMyComAddinProgId).Object.MyPublicPropertyOrMethod.
1. strMyComAddinProgId - see the ProgId attribute of your add-in module.
2. MyPublicPropertyOrMethod is called via late binding; see System.Type.InvokeMember in MSDN or seacrh trough this forum.
What do you think?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 23 Jul, 2010 07:42:08
|
|
Top
|
|
Daniel Rail
Posts: 14
Joined: 2008-10-03
|
I'll give it a try.
But, I also need that my add-in can update the Outlook contacts automatically, even if the stand-alone application is not running, since this is a multi-user application.
I'm currently trying to update the contacts using a timer. But, I'm encountering some problems. I'm getting the error: "COM object that has been separated from its underlying RCW cannot be used."
Top of callstack:
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at Microsoft.Office.Interop.Outlook.MAPIFolder.get_Items()
at LexPractica.MSOfficeAddins.AddinModule.LoadContacts() in C:\Users\Daniel Rail\Documents\Visual Studio 2008\Projects\AccraLaw\LexPractica.MSOfficeAddins\AddinModule.cs:line 1030
Here the code that starts at line 1030 in AddinModule.cs:
foreach (ContactItem vContactItem in LexPracticaContacts.Items)
{
DateTime vDateTime = (DateTime)vContactItem.UserProperties["LexPracticaLastSync"].Value;
if (vDateTime != null)
{
if (vDateTime > vLastSyncTimestamp)
{
vLastSyncTimestamp = vDateTime;
}
}
}
The foreach line is line 1030.
Any ideas how I can correct this error? |
|
Posted 23 Jul, 2010 09:33:41
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
Hi Daniel,
"COM object that has been separated from its underlying RCW" means the COM object is released while the .NET object is still alive. I cannot tell you why this occurs because the code above doesn't allow this.
Please read http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/.
In the code above you should use "for" instead of "foreach" and release a number of COM objects. Also, you must not release COM objects supplied to you in parameters of Add-in Express events.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 23 Jul, 2010 10:37:51
|
|
Top
|
|
Daniel Rail
Posts: 14
Joined: 2008-10-03
|
Hi,
The error that I was having was that I was referencing a variable that I assigned on startup that was supposed to contain a reference to the folder. But, obviously that seems to be something that I can't do. And, the RCW error disappeared when I dynamically lookup the folder and assigned it to a local variable, within the method. This permitted me to refresh the contacts using a timer.
But, I wasn't able to get your first suggestion working. I never used late binding before and I can't find a good example to see what I might be doing wrong. If you have a code sample it would be appreciated. |
|
Posted 26 Jul, 2010 07:20:04
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
|
Posted 26 Jul, 2010 08:17:58
|
|
Top
|
|