Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetOfficeFw not close Application if call by WebApi #392

Open
heavymanto opened this issue Jun 8, 2023 · 2 comments
Open

NetOfficeFw not close Application if call by WebApi #392

heavymanto opened this issue Jun 8, 2023 · 2 comments

Comments

@heavymanto
Copy link

heavymanto commented Jun 8, 2023

NetOfficeFw 1.9.3
Framework .NET6.0
VS 2022
SO Win 11

I have buid a simple example for test convertion in Pdf file

public static void ConvertExcel2Pdf(string excelPath, string pdfPath)
        {
            Workbook wkb = null;
            NetOffice.ExcelApi.Application app = new NetOffice.ExcelApi.Application(true);

            try
            {
                app.DisplayAlerts = false;
                app.Visible = false;

                wkb = app.Workbooks.Open(excelPath);
                wkb.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdfPath);
            }
            finally
            {
                // Cleanup
                wkb.Close(false);
                wkb.Dispose();
                app.Quit();

                WaitForComCleanup();
            }
        }

It work fine and close process if i call this method by Console App, but if i call via WebAPI

[HttpGet()]
        [Route("api/GetConvert2Pdf")]
        public string GetConvert2Pdf(string fullPathInputFile = @"c:\temp\TemplateExcel.xlsx")
        {
            try
            {
                string testFileInput = fullPathInputFile;
                string testFileOutput = @"c:\temp\TemplateExcel.pdf";

                ConvetDocumentUtility.ConvertExcel2Pdf(testFileInput, testFileOutput);
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

            return "Finish OK!";
        }

seem not to able to close to process

image

there is a workarround?

Thanks

@heavymanto heavymanto changed the title NetOfficeFw bot close Application if call by WebApi NetOfficeFw not close Application if call by WebApi Jun 8, 2023
@jozefizso
Copy link
Member

You must use memory profiler to test your application and track leaking references.

@heavymanto
Copy link
Author

I'm sorry, have you an example?
Thanks

M.F.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants