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

做~自己de王妃 提交于 2019-12-05 22:53:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23698462/marshal-getactiveobjectoutlook-application-throws-mk-e-unavailable-when-debu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!