Marshal.GetActiveObject() throws MK_E_UNAVAILABLE exception in C#

前端 未结 3 1174
名媛妹妹
名媛妹妹 2020-12-14 11:07

The following vbscript code works prefectly fine:

Dim App 
Set App = GetObject(\"\",\"QuickTest.Application\")
App.Quit

But when I translat

3条回答
  •  没有蜡笔的小新
    2020-12-14 11:24

    The issue can also be triggered by not running with elevated privileges. This seems to have changed over the years, so try all permutations of running either the IDE or the target program with or without elevated privileges.

    As of August 2017, to get the running instance of Outlook 365 under the Visual Studio 2015 debugger, I had to do the following to avoid the MK_E_UNAVAILABLE error:

    • Start Outlook as Administrator
    • Start Visual Studio as Administrator

    My program running in the debugger was then able to get the running instance of Outlook successfully.

提交回复
热议问题