惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - yo

Silverlight 缺陷 - yo - 博客园 SilverLight Controls WF 4.0 中 Persistence 异常 - yo SilverLight框架初探-View - yo - 博客园 SilverLight框架初探-RiaService SilverLight框架初探-ViewModel SilverLight框架初探 与客户“调情” AG_E_PARSER_BAD_PROPERTY_VALUE 定义属于自己的Routing 数据契约的序列化 WCF客户端配置问题 母版页中控件ID获取 - yo - 博客园 Reportviewer - Error: ASP.NET session has expired - yo SQL CLR C# DLL动态调用 Sharepoint List faults - yo 出错页面webpar的t删除 quickpart
关闭EXCEL进程
yo · 2009-06-04 · via 博客园 - yo

今天碰到了关闭EXCEL进程的麻烦,在网上找了半天,得到的结果基本都差不多。记得之前自己也使用过相似的办法来关闭EXCEL进程,没有出现什么问题。代码如下:

        Microsoft.Office.Interop.Excel.Application oExcel = null;
        oExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();

        ...................
        oExcel.Quit();
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel);
        GC.Collect();

最后终于让我找出了问题所在,原来我将oExcel定义为全局变量,所以在相应事件后进程还是驻留在内存中,并不能像我们所想的退出进程。所以,全局变量要慎用

但是当我打开某一文件后

oExcel.Workbooks.Open(filePath, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);

EXCEL进程又无法关闭,于是又找了些资料。发现原来应该是权限控制的问题:

1.控制面板-》管理工具-》组件服务-》计算机-》我的电脑-》DCom配置-》Microsoft Excel Application-》右键-》属性

2.单击“标识”选项卡,然后选择交互式用户

3.单击“安全”选项卡,将"访问权限"组设为"自定义",然后添加iusr_machinename和network service账户并启用远程控制权限

搞定!

如果还不行,那么就加上everyone账户,不过这样总感觉不太安全,不知道哪位大虾可有更好的解决方法