Excel.exe Process stays open in my "Task Manager" (C# ASP.Net Development)

Discussion in 'ASP .Net' started by Leeor Chernov, Dec 14, 2005.

  1. Hi ,
    I Used the object Excell Application(COM INTEROP) and it is staying as an
    open process, And the owner(User Name) is ASPNET
    Altough I try to release it with :
    System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
    Every time I am opening a new Excel.Application() , I get more Processes in
    memory.
    Note: I am calling the CreateExcellObj each time I am pressing a button from
    my web page
    The release Methods sometimes release few Excell processes but the last one
    always stays.

    The Init method:

    public void CreateExcellObj(string FilePath)
    {

    ExcelObj = new Excel.Application();


    ExcelObj.Visible = true;
    WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
    System.Reflection.Missing.Value,
    true,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value,
    System.Reflection.Missing.Value);

    }



    The Release methods:

    private void Release()
    {

    WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
    ssing.Value);
    ReleaseComObject(oSheet);

    ReleaseComObject(WorkBookObj);
    ExcelObj.Workbooks.Close();
    ReleaseComObject(ExcelObj.Workbooks);

    ExcelObj.Quit();
    ReleaseComObject(ExcelObj);

    //GC.WaitForPendingFinalizers();
    GC.Collect();

    DALObj.UpdateFromDTAndAdapter( curTable, null);
    return requestID;
    }

    private void ReleaseComObject(object ComObj)
    {

    int result;
    result =
    System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    // do
    // {
    // result =
    System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    // }
    // while( result == 0);
    ComObj = null;
    }


    How can I solve this problem

    Thank you

    Leeor Chernov
    R&D Department
    SPLSoftware LTD.
    ISRAEL
     
    Leeor Chernov, Dec 14, 2005
    #1
    1. Advertising

  2. I've seen some code in the performance newsgroup to loop thru the excel
    processes open and shut them down. You should have a google for that code
    and use it. Excel automation's biggest ugly spot is this.

    --
    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The Microsoft Office Web Components Black Book with .NET
    Now Available @ www.lulu.com/owc
    Forth-coming VSTO.NET - Wrox/Wiley 2006
    -------------------------------------------------------



    "Leeor Chernov" <> wrote in message
    news:...
    >
    >
    >
    > Hi ,
    > I Used the object Excell Application(COM INTEROP) and it is staying as an
    > open process, And the owner(User Name) is ASPNET
    > Altough I try to release it with :
    > System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
    > Every time I am opening a new Excel.Application() , I get more Processes

    in
    > memory.
    > Note: I am calling the CreateExcellObj each time I am pressing a button

    from
    > my web page
    > The release Methods sometimes release few Excell processes but the last

    one
    > always stays.
    >
    > The Init method:
    >
    > public void CreateExcellObj(string FilePath)
    > {
    >
    > ExcelObj = new Excel.Application();
    >
    >
    > ExcelObj.Visible = true;
    > WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
    > System.Reflection.Missing.Value,
    > true,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value);
    >
    > }
    >
    >
    >
    > The Release methods:
    >
    > private void Release()
    > {
    >
    >

    WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
    > ssing.Value);
    > ReleaseComObject(oSheet);
    >
    > ReleaseComObject(WorkBookObj);
    > ExcelObj.Workbooks.Close();
    > ReleaseComObject(ExcelObj.Workbooks);
    >
    > ExcelObj.Quit();
    > ReleaseComObject(ExcelObj);
    >
    > //GC.WaitForPendingFinalizers();
    > GC.Collect();
    >
    > DALObj.UpdateFromDTAndAdapter( curTable, null);
    > return requestID;
    > }
    >
    > private void ReleaseComObject(object ComObj)
    > {
    >
    > int result;
    > result =
    > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > // do
    > // {
    > // result =
    > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > // }
    > // while( result == 0);
    > ComObj = null;
    > }
    >
    >
    > How can I solve this problem
    >
    > Thank you
    >
    > Leeor Chernov
    > R&D Department
    > SPLSoftware LTD.
    > ISRAEL
    >
    >
    >
    >
    >
    >
     
    Alvin Bruney - ASP.NET MVP, Dec 14, 2005
    #2
    1. Advertising

  3. Leeor Chernov

    Morgan Guest

    You should not be using Excel (or any of the Office products) w/ ASP.Net. It
    is not threadsafe and not recommended by MS.


    "Leeor Chernov" <> wrote in message
    news:...
    >
    >
    >
    > Hi ,
    > I Used the object Excell Application(COM INTEROP) and it is staying as an
    > open process, And the owner(User Name) is ASPNET
    > Altough I try to release it with :
    > System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
    > Every time I am opening a new Excel.Application() , I get more Processes
    > in
    > memory.
    > Note: I am calling the CreateExcellObj each time I am pressing a button
    > from
    > my web page
    > The release Methods sometimes release few Excell processes but the last
    > one
    > always stays.
    >
    > The Init method:
    >
    > public void CreateExcellObj(string FilePath)
    > {
    >
    > ExcelObj = new Excel.Application();
    >
    >
    > ExcelObj.Visible = true;
    > WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
    > System.Reflection.Missing.Value,
    > true,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value,
    > System.Reflection.Missing.Value);
    >
    > }
    >
    >
    >
    > The Release methods:
    >
    > private void Release()
    > {
    >
    > WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
    > ssing.Value);
    > ReleaseComObject(oSheet);
    >
    > ReleaseComObject(WorkBookObj);
    > ExcelObj.Workbooks.Close();
    > ReleaseComObject(ExcelObj.Workbooks);
    >
    > ExcelObj.Quit();
    > ReleaseComObject(ExcelObj);
    >
    > //GC.WaitForPendingFinalizers();
    > GC.Collect();
    >
    > DALObj.UpdateFromDTAndAdapter( curTable, null);
    > return requestID;
    > }
    >
    > private void ReleaseComObject(object ComObj)
    > {
    >
    > int result;
    > result =
    > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > // do
    > // {
    > // result =
    > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > // }
    > // while( result == 0);
    > ComObj = null;
    > }
    >
    >
    > How can I solve this problem
    >
    > Thank you
    >
    > Leeor Chernov
    > R&D Department
    > SPLSoftware LTD.
    > ISRAEL
    >
    >
    >
    >
    >
    >
     
    Morgan, Dec 14, 2005
    #3
  4. You really ought to qualify that statement. The recommendation concerns
    server-side usage. Client-side usage is fine. Asp.NET can do both client and
    server.

    --
    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The Microsoft Office Web Components Black Book with .NET
    Now Available @ www.lulu.com/owc
    Forth-coming VSTO.NET - Wrox/Wiley 2006
    -------------------------------------------------------



    "Morgan" <> wrote in message
    news:...
    > You should not be using Excel (or any of the Office products) w/ ASP.Net.

    It
    > is not threadsafe and not recommended by MS.
    >
    >
    > "Leeor Chernov" <> wrote in message
    > news:...
    > >
    > >
    > >
    > > Hi ,
    > > I Used the object Excell Application(COM INTEROP) and it is staying as

    an
    > > open process, And the owner(User Name) is ASPNET
    > > Altough I try to release it with :
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
    > > Every time I am opening a new Excel.Application() , I get more Processes
    > > in
    > > memory.
    > > Note: I am calling the CreateExcellObj each time I am pressing a button
    > > from
    > > my web page
    > > The release Methods sometimes release few Excell processes but the last
    > > one
    > > always stays.
    > >
    > > The Init method:
    > >
    > > public void CreateExcellObj(string FilePath)
    > > {
    > >
    > > ExcelObj = new Excel.Application();
    > >
    > >
    > > ExcelObj.Visible = true;
    > > WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
    > > System.Reflection.Missing.Value,
    > > true,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value);
    > >
    > > }
    > >
    > >
    > >
    > > The Release methods:
    > >
    > > private void Release()
    > > {
    > >
    > >

    WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
    > > ssing.Value);
    > > ReleaseComObject(oSheet);
    > >
    > > ReleaseComObject(WorkBookObj);
    > > ExcelObj.Workbooks.Close();
    > > ReleaseComObject(ExcelObj.Workbooks);
    > >
    > > ExcelObj.Quit();
    > > ReleaseComObject(ExcelObj);
    > >
    > > //GC.WaitForPendingFinalizers();
    > > GC.Collect();
    > >
    > > DALObj.UpdateFromDTAndAdapter( curTable, null);
    > > return requestID;
    > > }
    > >
    > > private void ReleaseComObject(object ComObj)
    > > {
    > >
    > > int result;
    > > result =
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > > // do
    > > // {
    > > // result =
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > > // }
    > > // while( result == 0);
    > > ComObj = null;
    > > }
    > >
    > >
    > > How can I solve this problem
    > >
    > > Thank you
    > >
    > > Leeor Chernov
    > > R&D Department
    > > SPLSoftware LTD.
    > > ISRAEL
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Alvin Bruney - ASP.NET MVP, Dec 14, 2005
    #4
  5. Hi Morgan ,
    Can you send me an article-link that it isnot recomended?
    And anyway it is MS product and the problem is to release the process...




    "Morgan" <> ëúá
    áäåãòä:...
    > You should not be using Excel (or any of the Office products) w/ ASP.Net.

    It
    > is not threadsafe and not recommended by MS.
    >
    >
    > "Leeor Chernov" <> wrote in message
    > news:...
    > >
    > >
    > >
    > > Hi ,
    > > I Used the object Excell Application(COM INTEROP) and it is staying as

    an
    > > open process, And the owner(User Name) is ASPNET
    > > Altough I try to release it with :
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
    > > Every time I am opening a new Excel.Application() , I get more Processes
    > > in
    > > memory.
    > > Note: I am calling the CreateExcellObj each time I am pressing a button
    > > from
    > > my web page
    > > The release Methods sometimes release few Excell processes but the last
    > > one
    > > always stays.
    > >
    > > The Init method:
    > >
    > > public void CreateExcellObj(string FilePath)
    > > {
    > >
    > > ExcelObj = new Excel.Application();
    > >
    > >
    > > ExcelObj.Visible = true;
    > > WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
    > > System.Reflection.Missing.Value,
    > > true,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value,
    > > System.Reflection.Missing.Value);
    > >
    > > }
    > >
    > >
    > >
    > > The Release methods:
    > >
    > > private void Release()
    > > {
    > >
    > >

    WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
    > > ssing.Value);
    > > ReleaseComObject(oSheet);
    > >
    > > ReleaseComObject(WorkBookObj);
    > > ExcelObj.Workbooks.Close();
    > > ReleaseComObject(ExcelObj.Workbooks);
    > >
    > > ExcelObj.Quit();
    > > ReleaseComObject(ExcelObj);
    > >
    > > //GC.WaitForPendingFinalizers();
    > > GC.Collect();
    > >
    > > DALObj.UpdateFromDTAndAdapter( curTable, null);
    > > return requestID;
    > > }
    > >
    > > private void ReleaseComObject(object ComObj)
    > > {
    > >
    > > int result;
    > > result =
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > > // do
    > > // {
    > > // result =
    > > System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
    > > // }
    > > // while( result == 0);
    > > ComObj = null;
    > > }
    > >
    > >
    > > How can I solve this problem
    > >
    > > Thank you
    > >
    > > Leeor Chernov
    > > R&D Department
    > > SPLSoftware LTD.
    > > ISRAEL
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Leeor Chernov, Dec 15, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ioannis
    Replies:
    4
    Views:
    3,737
    Jonathan N. Little
    Jun 27, 2006
  2. Alan
    Replies:
    8
    Views:
    695
    rossum
    Jun 24, 2005
  3. Artem Kazakov
    Replies:
    5
    Views:
    140
    John Carter
    May 23, 2008
  4. Ash
    Replies:
    0
    Views:
    602
  5. dorayme

    Dropdown menu stays open in IE7

    dorayme, Sep 17, 2008, in forum: Javascript
    Replies:
    2
    Views:
    161
    dorayme
    Sep 18, 2008
Loading...

Share This Page