L
lostwings
hi,
I am writing a COM Addin for outlook using .Net Framwork 2.0, which
generates the managed code. However, the host application Outlook 2003
belongs to the unmanaged world. In the CLR environment, the .Net Framework
will do the garbage collection automatically but in an undeteministic way,
that means I don't have any idea of exactly when the memory will be released.
Therefore it might have some potential problems if I don't write explicitly
the garbage collection code in the Com Add in. For instance, if I close the
outlook 2003, which has already load the COM add-in, and then quickly reopen
that outlook 2003. The system will pop out a messgge says like "operation
failed". I guess that's because I don't do the garbage collection, is that
correct?
To solve this issue, I try to raise the quit event handler for the
outlook.application object. In that handler, it basically does the following
outlookApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
However, the problem is not solved successfully by using that way. I am
doubting if I should put such code in somewhere else?
Any suggestion would be greatly appreciated.
I am writing a COM Addin for outlook using .Net Framwork 2.0, which
generates the managed code. However, the host application Outlook 2003
belongs to the unmanaged world. In the CLR environment, the .Net Framework
will do the garbage collection automatically but in an undeteministic way,
that means I don't have any idea of exactly when the memory will be released.
Therefore it might have some potential problems if I don't write explicitly
the garbage collection code in the Com Add in. For instance, if I close the
outlook 2003, which has already load the COM add-in, and then quickly reopen
that outlook 2003. The system will pop out a messgge says like "operation
failed". I guess that's because I don't do the garbage collection, is that
correct?
To solve this issue, I try to raise the quit event handler for the
outlook.application object. In that handler, it basically does the following
outlookApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
However, the problem is not solved successfully by using that way. I am
doubting if I should put such code in somewhere else?
Any suggestion would be greatly appreciated.