当前位置: 移动技术网 > IT编程>开发语言>.net > [古怪问题] Marshal.GetActiveObject 在管理员模式下无法正常运行

[古怪问题] Marshal.GetActiveObject 在管理员模式下无法正常运行

2019年03月08日  | 移动技术网IT编程  | 我要评论

阿拉伯之星,元旦放几天,好牛168

问题:

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.

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网