locked
Best practice for MS office interop cleanup RRS feed

  • Question

  • User591929525 posted

    Folks,

    When disposing of MS word interop objects created in an asp.net app, can someone advise me on best practice?

    I have an application that creates word docs from a template and stores the docs in SQL server. I need to ensure garbage collection works everytime.

    Cheers

     

    Tuesday, August 26, 2008 5:56 AM

All replies

  • User449345775 posted

    When I used interop objects, after i finish using them I set the objects to nothing and call the "collect" method of the gabage collector class by Gc.collect().

    Regards

    Tuesday, August 26, 2008 6:37 AM
  • User591929525 posted

    Thanks,

    Anyone using......
    GC.WaitForPendingFinalizers();
    Marshal.FinalReleaseComObject(oWordDoc);

    Tuesday, August 26, 2008 9:37 AM