Proper disposal of COM interop objects in C# particularly MS Office applications

前端 未结 3 1957
耶瑟儿~
耶瑟儿~ 2020-12-31 08:42

I am developing an application that relies heavily on multiple Microsoft Office products including Access, Excel, Word, PowerPoint and Outlook among others. While doing rese

3条回答
  •  温柔的废话
    2020-12-31 09:00

    Objects should be disposed automatically by the GC after the object goes out of scope. If you need to release them sooner, you can use Marshal.ReleaseComObject http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx

提交回复
热议问题