문제

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?

도움이 되었습니까?

해결책

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."

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top