Release Excel Object In My Destructor

后端 未结 3 1818
北荒
北荒 2020-12-06 02:53

I\'m writing a Excel class using Microsoft.Interropt.Excel DLL. I finish all function but I have an error in my Destructor. I Want to save all changes to my file and I want

3条回答
  •  余生分开走
    2020-12-06 03:28

    No, you should not be accessing any managed objects in a destructor: this includes COM RCWs.

    Instead, implement the standard IDisposable pattern, and release your COM objects in the Dispose(bool) method like you would a disposable managed object.

提交回复
热议问题