Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Marshal.GetActiveObject("Outlook.Application") throws MK_E_UNAVAILABLE when debugging with elevated privileges

This code run without problem in release r debug when Visual studio isn't started as an admin.

Marshal.GetActiveObject("Outlook.Application");

However, when I start Vs as administrator and run the same line in debug, I get the following error:

System.Runtime.InteropServices.COMException
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

How can I fix this.

like image 817
Justin Lessard Avatar asked May 16 '14 14:05

Justin Lessard


1 Answers

I would guess that you are running Visual Studio as Administrator (started via Run as Administrator) while Outlook was opened as user, who was logged in as under Windows logon. So the Visual Studio is running under different user than Outlook client.

like image 77
RostaX Avatar answered Oct 31 '22 17:10

RostaX