| InnerException |
F Cali provided a rated reply to . . on Wednesday, October 04, 2006 5:20 PM |
|
Try checking the InnerException of your exception and see if this will give a more descriptive error message that what you are currently getting. |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
3 |
$65.00 |
168 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| COMException |
| . . replied to F Cali on Wednesday, October 04, 2006 5:55 PM |
|
Hi Ron!
Some good news:
I added a try / catch block and now I always logoff from Outlook namespace... error shows me this:
Microsoft Office Outlook A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Phone Usage Reporter.exe at Outlook.ItemsClass.get_Item(Object Index) at Phone_Usage_Reporter.formMain.linkUpdate_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) in C:\Documents and Settings\itsadmin\My Documents\Visual Studio 2005\Projects\Toolbox\Phone Usage Reporter\Phone Usage Reporter\Form1.cs:line 39
and now it always reads 164 items... no more...
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| 0-Based |
F Cali provided a rated reply to . . on Wednesday, October 04, 2006 5:59 PM |
|
In C#, indexes are 0-based. Given this, try changing the ones in red:
for (int i = 0; i < mexicoContacts.Items.Count; i++) {
if (mexicoContacts.Items[i] is Outlook.ContactItem) {
Outlook.ContactItem contact = (Outlook.ContactItem)mexicoContacts.Items[i]; if (contact.LastName != null) listBox1.Items.Add(contact.LastName);
}
}
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
3 |
$65.00 |
168 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| 166 but no 165 |
| . . replied to F Cali on Wednesday, October 04, 2006 6:07 PM |
|
I tried, but seems Outlook has a 1-based array system... item 0 does not exist... I have something else: I can read item 166 but can't read item 165... strange... that makes me think it's something related to the way the item was saved...
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| Skip Erroneous Items |
F Cali provided a rated reply to . . on Wednesday, October 04, 2006 6:10 PM |
|
Looks like there's something wrong with that item. I suggest that you skip those items that gives you an error and just continue with the items after that and just report which ones are causing the problem. |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
3 |
$65.00 |
168 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| Sounds easy but... |
| . . replied to F Cali on Wednesday, October 04, 2006 6:24 PM |
|
hehe, sounds easy, but I don't know how to skip this... it seems like Outlook does not have an order in this numbers... :-)
maybe doing a foreach, but how would you do it?
thanks
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| try/catch inside for loop |
F Cali provided a rated reply to . . on Wednesday, October 04, 2006 6:26 PM |
|
One way to do it is to put your try/catch inside the for loop instead of outside:
for (int i = 1; i <= mexicoContacts.Items.Count; i++) {
try {
if (mexicoContacts.Items[i] is Outlook.ContactItem) {
Outlook.ContactItem contact = (Outlook.ContactItem)mexicoContacts.Items[i]; if (contact.LastName != null) listBox1.Items.Add(contact.LastName); }
}
catch (Exception exception) {
}
}
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
3 |
$65.00 |
168 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| Hey!!! |
| . . replied to F Cali on Wednesday, October 04, 2006 6:33 PM |
|
You're the man!!! I got all of them! got a big bunch of this:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Phone Usage Reporter.exe
but there they are... I also changed for loop to this:
int total = mexicoContacts.Items.Count;
for (int i = 1; i <= total; i++)
because asking many times for mexicoContacts.Items.Count's value also raised an exception... do you any idea why this happened?
anyway it works now... thanks!!!!
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|