![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi all.
I develop vsto addIn 2005, OL 2003, C# 2.0 One of my customer sometime got comException -- System.Runtime.InteropServices.COMException (0xB174010F): The operation failed. at Microsoft.Office.Interop.Outlook.MAPIFolder.get_Na me() In the code we try to get Folder's name. Why this happen?? How can i recover from this error?? (otlook restart helps, but this is not solution.) Thanks in advance. |
#2
|
|||
|
|||
![]()
The obvious question is if that MAPIFolder object is valid when you ask for
the folder name? Do you check that? If it is a valid folder I can't think of a reason why the name isn't available. In general with COM addins you should be handling all possible errors. With managed code you have to do even more exception handling than you would with unmanaged code, things are less forgiving with managed code. You need to put try...catch blocks around any code that could fire an exception, and you need to test for things such as properties like EntryID. In unmanaged code an item that was never saved will have a null string EntryID, in managed code the property may not be there. So you'd need to test for String.IsNullOrEmpty(). You should also not use compound dot operators, which create invisible variables you can't release, and which make it impossible to see exactly where any code is failing. -- 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 "j" wrote in message ... Hi all. I develop vsto addIn 2005, OL 2003, C# 2.0 One of my customer sometime got comException -- System.Runtime.InteropServices.COMException (0xB174010F): The operation failed. at Microsoft.Office.Interop.Outlook.MAPIFolder.get_Na me() In the code we try to get Folder's name. Why this happen?? How can i recover from this error?? (otlook restart helps, but this is not solution.) Thanks in advance. |
#3
|
|||
|
|||
![]()
On Jul 28, 4:13*pm, "Ken Slovak - [MVP - Outlook]"
wrote: The obvious question is if that MAPIFolder object is valid when you ask for the folder name? Do you check that? If it is a valid folder I can't think of a reason why the name isn't available. In general with COM addins you should be handling all possible errors. With managed code you have to do even more exception handling than you would with unmanaged code, things are less forgiving with managed code. You need to put try...catch blocks around any code that could fire an exception, and you need to test for things such as properties like EntryID. In unmanaged code an item that was never saved will have a null string EntryID, in managed code the property may not be there. So you'd need to test for String.IsNullOrEmpty(). You should also not use compound dot operators, which create invisible variables you can't release, and which make it impossible to see exactly where any code is failing. -- 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 "j" wrote in message ... Hi all. I develop vsto addIn 2005, OL 2003, C# 2.0 One of my customer sometime got comException -- System.Runtime.InteropServices.COMException (0xB174010F): The operation failed. * at Microsoft.Office.Interop.Outlook.MAPIFolder.get_Na me() In the code we try to get Folder's name. Why this happen?? How can i recover from this error?? (otlook restart helps, but this is not solution.) Thanks in advance.- Hide quoted text - - Show quoted text - Thanks for replay, can please explain what you meant by saying : The obvious question is if that MAPIFolder object is valid when you ask for the folder name? Do you check that? If it is a valid folder I can't think of a reason why the name isn't available. How should i check if this object valid??? some sample will help. Also, some time i got comException when trying to access the toolbar: "Microsoft.Office.Interop.Outlook.ExplorerClass.ge t_CommandBars" what can i do on the subject. Thanks. |
#4
|
|||
|
|||
![]()
Before using something like this:
Debug.WriteLine(folder.Name); You should use code something like this: if (folder != null) { Debug.WriteLine(folder.Name); } The same thing applies to any other object such as a CommandBar. -- 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 "j" wrote in message ... snip Thanks for replay, can please explain what you meant by saying : The obvious question is if that MAPIFolder object is valid when you ask for the folder name? Do you check that? If it is a valid folder I can't think of a reason why the name isn't available. How should i check if this object valid??? some sample will help. Also, some time i got comException when trying to access the toolbar: "Microsoft.Office.Interop.Outlook.ExplorerClass.ge t_CommandBars" what can i do on the subject. Thanks. |
#5
|
|||
|
|||
![]()
On Jul 28, 5:32*pm, "Ken Slovak - [MVP - Outlook]"
wrote: Before using something like this: Debug.WriteLine(folder.Name); You should use code something like this: * * if (folder != null) * * { * * * * Debug.WriteLine(folder.Name); * * } The same thing applies to any other object such as a CommandBar. -- 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 "j" wrote in message ... snip Thanks for replay, can please explain what you meant by saying : The obvious question is if that MAPIFolder object is valid when you ask for the folder name? Do you check that? If it is a valid folder I can't think of a reason why the name isn't available. How should i check if *this object valid??? some sample will help. Also, some time i got comException when trying to access the toolbar: "Microsoft.Office.Interop.Outlook.ExplorerClass.ge t_CommandBars" what can i do on the subject. Thanks. Thank you, I got it, now my question is what should i do if i get null in COMMANDBARS?? by the way i'm moreo then sure, that these objects not NULL, and still they ends up with ComExcpetion. What do you say?? |
#6
|
|||
|
|||
![]()
If a MAPIFolder is not null then you can get its properties. Set a
breakpoint at that line of code and use the Locals window to see what properties are exposed on that COM object. Same thing for CommandBars. Any Explorer will have a valid CommandBars collection. If you get a valid Explorer I can't see why you wouldn't be able to get the CommandBars collection for it. Again, use the Locals window to see what's up. -- 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 "j" wrote in message ... snip Thank you, I got it, now my question is what should i do if i get null in COMMANDBARS?? by the way i'm moreo then sure, that these objects not NULL, and still they ends up with ComExcpetion. What do you say?? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
The operation failed. | gorahilly | Outlook - Calandaring | 0 | December 11th 08 07:26 PM |
The Operation Failed | Big Iv | Outlook - Calandaring | 0 | June 10th 08 07:08 PM |
The Operation Failed... | Billingsley | Outlook - General Queries | 0 | September 24th 07 08:03 PM |
Operation Failed | alamb200 | Outlook - General Queries | 2 | March 26th 07 09:47 AM |
Operation Failed | techjunkee | Outlook - Installation | 2 | March 21st 06 10:40 PM |