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

8

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.

c#
.net
visual-studio-2013
com-interop
elevated-privileges
asked on Stack Overflow May 16, 2014 by Justin • edited May 16, 2014 by Justin

1 Answer

12

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.

answered on Stack Overflow Sep 21, 2014 by RostaX

User contributions licensed under CC BY-SA 3.0