Failure creating an Outlook application object on Vista

While creating a Outlook application object from another process in C# like:

outlook = new Microsoft.Office.Interop.Outlook.Application();

or powershell

PS> $outlook = new-object -com Outlook.Application

or straight up COM via CoCreateInstance on Vista it's possible to receive the following error:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005

Error 0x80080005 (CO_E_SERVER_EXEC_FAILURE) is sort of a generic COM error message that occurs for many reasons while calling CoCreateInstance. One reason someone could receive this error is because the client process and the server process (outlook.exe in this case) are running at different integrity levels. By default it doesn't appear that COM likes talking across two different processes that are running at different integrity levels. There supposedly is a way to implement the COM server in such a way to support it but currently the Outlook COM server doesn't support it.

People who develop their applications on Vista using Visual Studio, which runs at integrity level high by default, will run into this issue often when Outlook is already running. By default Outlook runs at integrity level medium and if the client application is run from Visual Studio it will inherit the high integrity level and thus there will be an integrity level mismatch.

To fix this one needs to make the integrity levels match so either start the client application outside Visual Studio at the normal medium integrity level or run Outlook at the high integrity level (i.e. as Administrator). However it is not recommended to run Outlook at integrity level high all the time. Another way to deal with this is to ensure Outlook is not already running so COM will start the process at the correct integrity level of the client process that created the application object.

I don't know of any way to detect this exact situation programmatically but process explorer works well for manually checking the integrity levels of processes.

Published Monday, November 5, 2007 12:56 AM by puzzlehacker
Filed under: , ,

Comments

# re: Failure creating an Outlook application object on Vista

This caused me to scream and curse for several hours when I migrated somes clients from XP Pro/O2003 to Vista Business/O2007.

My (HACKISH) solution was to launch Outlook as Administrator, but its nice to have more information.

I'll look into running both Outlook and the .Net application at Medium Integrity level I guess.

Monday, November 5, 2007 8:15 PM by Torteth

# re: Failure creating an Outlook application object on Vista

It seems that this problem only repro in OS running Vista x64.  Vista x86 does not run into this problem.  Has anyone found this oddity as well?

Friday, November 30, 2007 5:19 PM by Isaac

# re: Failure creating an Outlook application object on Vista

Hi Wes,

I want to open address book in a winform application. I am able to retrieve contacts and populate them in a listview but i need to retrieve the contacts from the Address book.How can I achive this?

Any help on this will be greatly appreciated.

Thanks and regards,

Vicky

vivek.minhas@catalytic.com

Thursday, December 6, 2007 5:51 AM by Vicky

# re: Failure creating an Outlook application object on Vista

Vicky have a look at the AddressLists that appear on the Namespace object.

Thursday, December 6, 2007 11:00 AM by puzzlehacker

# re: Failure creating an Outlook application object on Vista

hello,

anybody sollution? the bellow code is not working in vista

objOutlk = new ActiveXObject("Outlook.Application")

In XP the above javascript code works fine to open outlook in web page to open as client side , but it doesnt work in vista! can anyone help?

Many thanks

Thursday, April 9, 2009 5:36 AM by senthil