问题:

var obj = Marshal.GetActiveObject("PowerPoint.Application")

该代码在管理员模式下运行无法正常获取正在运行的 PPT PowerPoint.Application 对象,而在非管理员模式下可以正常获取。

针对该问题,微软的msdn官方文档,也没有给予说明。

https://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.interopservices.marshal.getactiveobject?redirectedfrom=MSDN&view=netframework-4.7.2#%E5%AE%89%E5%85%A8%E6%80%A7

搜索资料:

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

怀疑 :和用户有关,没有直接证据。

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.

answer :
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.
 
 
验证怀疑:用管理员方式运行PPT, 用管理员方式运行该代码。 也是无法正常获取到对象。
 
 
 

最新文章

  1. Cent0S 升级Python会带来的问题
  2. 2013长沙邀请赛A So Easy!(矩阵快速幂,共轭)
  3. row_number() over order by与利用rownum查询分页效率分析
  4. SurfaceOutput
  5. jQuery的attr与prop,attribute和property区别
  6. 命令行 更新Android sdk
  7. 日常css和js小知识点记录
  8. android 添加依赖的库文件
  9. iOS的view翻转动画实现--代码老,供参考
  10. Android(java)学习笔记250:ContentProvider使用之获得系统联系人信息02(掌握)
  11. java.lang.ClassNotFoundException与java.lang.NoClassDefFoundError的区别(转)
  12. 乐在其中设计模式(C#) - 观察者模式(Observer Pattern)
  13. windbg 之 如何定位进程入口点地址
  14. nginx+lua安装配置
  15. 使用windows 命令行执行Git clone时出现Host key error
  16. project2
  17. MR程序本地调试,提交到集群运行
  18. module 'sign.views' has no attribute 'search_name'
  19. 20165237 2017-2018-2 《Java程序设计》第2周学习总结
  20. BZOJ2863[SHOI2012]魔法树——树链剖分+线段树

热门文章

  1. Java中System类的相关应用
  2. netty简单NIO模型
  3. UVA 508 Morse Mismatches JAVA
  4. 大数据环境完全分布式搭建 hadoop2.4.1
  5. HOJ3237----BFS/DFS
  6. Java笔记(十五) 并发包
  7. 基于Systick系统时钟延时的LED闪烁灯
  8. BZOJ4218 : 不知道高到哪里去了
  9. C++程序设计方法1:分离代码
  10. select 多选 (EasyUI)