Release COM Object in C#

后端 未结 2 972
萌比男神i
萌比男神i 2021-01-05 20:25

I know this has been discussed earlier but I couldn\'t find a satisfactory answer.

I have an e-mail file (.msg) which I open like below and then call Display.

2条回答
  •  礼貌的吻别
    2021-01-05 21:07

    If you're using .NET's COM-interop features (you are) then you shouldn't need to worry about this.

    COM tracks reference counts - and when the ref count reaches 0 COM objects get released automatically - and .NET takes care of working with the standard COM reference counting mechanism for you.

    If you were P/Invoking into a C library things might be different - but you shouldn't have any worries in a standard scenario like yours.

提交回复
热议问题