Excel 应用程序在内存中不断增长
我在 IIS 上有一个 ASP.net 应用程序。 在此应用程序中,我创建了一个 Excel 应用程序:
using Excel = Microsoft.Office.Interop.Excel;
public Excel.Application ExlApp;
//
public Excel.Workbook ExlWb;
//
public Excel.Worksheet ExlWs;
在应用程序工作期间,我创建了一个新工作簿,最后,我销毁了我的对象:
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(ExlWs);
ExlWb.Close(Type.Missing, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(ExlWb);
问题:在工作期间,EXCEL 进程在内存中增长,我如何关闭工作簿正确的?
I have a ASP.net application on IIS.
In this app I created a Excel application:
using Excel = Microsoft.Office.Interop.Excel;
public Excel.Application ExlApp;
//
public Excel.Workbook ExlWb;
//
public Excel.Worksheet ExlWs;
During the application work, I created a new workbooks and in finally, I destroy my objects:
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(ExlWs);
ExlWb.Close(Type.Missing, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(ExlWb);
The problem: during the work, the EXCEL proces is growing up in memory, how can I close the workbooks correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您应该考虑用 OpenXML 处理替换 Excel 自动化。自动化办公应用程序服务器端是不受支持的方案:
http://support.microsoft.com/kb/257757
“Microsoft 目前不建议也不支持从任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)实现 Microsoft Office 应用程序的自动化,因为 Office 可能会表现出当 Office 在此环境中运行时,行为不稳定和/或死锁。”
Maybe you should look at replacing the Excel automation with OpenXML processing. Automating office applications server side is an unsupported scenario:
http://support.microsoft.com/kb/257757
"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."