Unexpected and really weird hang-up due to folder creation and message box display in Outlook 2010 during debug only

StackOverflow https://stackoverflow.com/questions/12322692

Pregunta

Sorry for the title... This would easily win "the weirdest thingy of the week". I hope someone at least can give me a hint on how to investigate what's going on here...

When i run my add-in using Outlook, everything works as supposed to and I get no freeze-up.

However, when I try to do the same from VS10 in debug mode, I get to the splash screen and I get stuck there. First, I get to see a flash screen loading the add-in. Then it disappears and after a while, it appears again, keeps animating (the color wave on Office 2010 splash screens) and blinking with dots next to the "Processing"-text.

I am able to cancel it and close the splash screen (upon which Outlook shuts down without being displayed), so the application isn't frozen, apparently. Also, let me remind that when run by starting Outlook, everything works perfectly.

Now the weird part and hold on to your hats because it's REALLY weird.

The behavior only appears when I do both of the following things.

  1. Adding a new folder for contacts (see the code #1 below).
  2. Showing a welcome message in Outlook (see the code #2 below).

Code #1 is executed before code #2. If I skip (1), the hung-up goes away. If I skip (2), it also goes away. It's the mix of those two that causes the problem (only in debug mode). I'd love to get some explanation why the duck (not a typo - the bird is intended) this happens.

Code #1:

Outlook.Folder contacts = this.Application.Session.GetDefaultFolder(
  Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
Outlook.Folder addressBook = contacts.Folders.Add(
  "My AB", Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;

Code #2

MessageBox.Show("Coolest add-in ever! Gimme $$$!");
¿Fue útil?

Solución

I might know what causes the problem. I can only offer a work-around without an explanation as to WHY that happens.

It occurred to me that it MIGHT have to do with some confusion in UI so I went ALT-TAB-ing and there it was. A hidden message box. Once you click it, the program proceeds.

Don't ask me why or how...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top