Excel.Application.Quit在C#中不起作用? [英] Excel.Application.Quit Does not work in C# ?

查看:212
本文介绍了Excel.Application.Quit在C#中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我使用此代码段来关闭Excel文件.但这似乎不起作用.
原因:执行此操作后,我有一个断点,当我打开任务管理器时,仍然可以在进程"选项卡中看到EXCEL.EXE进程正在运行.
这可能会引起严重的记忆问题.
谁能帮帮我.

Hello All,
I use this code piece to close an excel file. but this does not seem to work.
Reason:After executing this i have a breakpoint and when i open task manager i still see the EXCEL.EXE process running in my processes tab.
This might cause seriour problems for my memory .
Can any one help me out.

XLFile.Close(false, XLFile.Name, false);
StartExcel.Quit();

推荐答案

由于.NET具有自动垃圾收集功能,因此收集器有时可能需要一些时间才能识别出它已经完成了...

Because .NET has automatic garbage collection it can sometimes take some time for the collector to recognize that it''s finished...

Marshal.ReleaseComObject(...);

这可以帮助加快速度并主动命令它释放excel(或任何其他com对象)

看看这个:
http://www.craigmurphy.com/blog/?p=82 [

this can help speed this up and actively order it to release excel (or any other com object)

Have a look at this:
http://www.craigmurphy.com/blog/?p=82[^]

Good luck!


这篇关于Excel.Application.Quit在C#中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆