Answered by:
Best practices of exception handling in Outlook Addin

Question
-
I am developing outlook addin for Outlook 2003 using C#. Everything works fine, but I am finding difficulty on getting the exception details from Outlook when there is an exception. I am using Invoke() method to do the COM call. When this fails, all I get is a COMException and a TragetInvocationException as inner exception. I am wondering is this the right behaviour? Outlook won't give meaningful error messages? If it gives, how can I get them in my application?
Any help would be great.
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.NMonday, November 1, 2010 12:13 PM
Answers
-
The recommended way of interfacing is by using a PIA. It's faster than using reflection.There most certainly are PIA's for Office 2003, I use them in almost every project I write. If I'm supporting 2003 - 2010 with one project I develop it using the 2003 PIA's on a development machine that has Office 2003 installed on 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"Navaneeth" <=?utf-8?B?TmF2YW5lZXRo?=> wrote in message news:5fc63c2e-d18e-4479-b239-07b22c956e6f...What do you mean you're using Invoke(), are you using reflection to make all your object model calls and not using a PIA? About all you could do in that case would be to try to get the COM exception error number if you can.Yes, I am using reflection to do the call. AFAIK, PIA is supported only from Office 2007 and doesn't have any support on 2003. Am I correct?
Also what is the recommended way of interacting with Outlook on 2003 version?
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.N
Ken Slovak MVP - Outlook- Marked as answer by Bessie Zhao Monday, November 8, 2010 9:08 AM
Tuesday, November 2, 2010 1:50 PM
All replies
-
What do you mean you're using Invoke(), are you using reflection to make all your object model calls and not using a PIA? About all you could do in that case would be to try to get the COM exception error number if you can.
--
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"Navaneeth" <=?utf-8?B?TmF2YW5lZXRo?=> wrote in message news:f3acaed0-08e4-42b2-b7e6-07ca6106f921...I am developing outlook addin for Outlook 2003 using C#. Everything works fine, but I am finding difficulty on getting the exception details from Outlook when there is an exception. I am using Invoke() method to do the COM call. When this fails, all I get is a COMException and a TragetInvocationException as inner exception. I am wondering is this the right behaviour? Outlook won't give meaningful error messages? If it gives, how can I get them in my application?
Any help would be great.
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.N
Ken Slovak MVP - OutlookMonday, November 1, 2010 2:02 PM -
What do you mean you're using Invoke(), are you using reflection to make all your object model calls and not using a PIA? About all you could do in that case would be to try to get the COM exception error number if you can.
Yes, I am using reflection to do the call. AFAIK, PIA is supported only from Office 2007 and doesn't have any support on 2003. Am I correct?
Also what is the recommended way of interacting with Outlook on 2003 version?
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.NTuesday, November 2, 2010 4:04 AM -
The recommended way of interfacing is by using a PIA. It's faster than using reflection.There most certainly are PIA's for Office 2003, I use them in almost every project I write. If I'm supporting 2003 - 2010 with one project I develop it using the 2003 PIA's on a development machine that has Office 2003 installed on 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"Navaneeth" <=?utf-8?B?TmF2YW5lZXRo?=> wrote in message news:5fc63c2e-d18e-4479-b239-07b22c956e6f...What do you mean you're using Invoke(), are you using reflection to make all your object model calls and not using a PIA? About all you could do in that case would be to try to get the COM exception error number if you can.Yes, I am using reflection to do the call. AFAIK, PIA is supported only from Office 2007 and doesn't have any support on 2003. Am I correct?
Also what is the recommended way of interacting with Outlook on 2003 version?
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.N
Ken Slovak MVP - Outlook- Marked as answer by Bessie Zhao Monday, November 8, 2010 9:08 AM
Tuesday, November 2, 2010 1:50 PM -
The recommended way of interfacing is by using a PIA. It's faster than using reflection.There most certainly are PIA's for Office 2003, I use them in almost every project I write. If I'm supporting 2003 - 2010 with one project I develop it using the 2003 PIA's on a development machine that has Office 2003 installed on it.
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.NWednesday, November 3, 2010 3:30 AM -
You may get only a COM exception and possibly an error number or message in the inner exception. In most cases the information is minimal however.
--
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"Navaneeth" <=?utf-8?B?TmF2YW5lZXRo?=> wrote in message news:b54dfe4e-282a-4792-8044-b9fb061a1291...The recommended way of interfacing is by using a PIA. It's faster than using reflection.There most certainly are PIA's for Office 2003, I use them in almost every project I write. If I'm supporting 2003 - 2010 with one project I develop it using the 2003 PIA's on a development machine that has Office 2003 installed on it.
*Mark the best reply as "Answered"
Sincerly,
Navaneeth.K.N
Ken Slovak MVP - Outlook- Proposed as answer by Bessie Zhao Monday, November 8, 2010 9:08 AM
Wednesday, November 3, 2010 2:14 PM