I have been developing office solutions in VBA for some time now and have quite comprehensive knowledge in the field of office development in VBA. I decided it was time to learn some real programs with .Net, and I have problems with slots.
After looking at a bunch of articles and forums (here and elsewhere), there seems to be some mixed information about memory management in .NET when using COM objects.
Some people say that I should always determine the release of COM objects, while others say that I will almost never do this.
People say I have to do this:
Excel Professional Development Book on page 861.
This question about file sharing answered: "Every link that you make to a COM object must be released. If you do not, the process will remain in memory"
This blog suggests using it to solve your problems.
People say that I should not do this:
Eric Carter's MSDN blog post says, "In VSTO scripts, you usually don't need to use ReleaseCOMObject."
The book "VSTO for Office 2007" , which co-authored with Eric Carter, does not seem to mention memory management or ReleaseComObject.
This Paul Harrington MSDN blog says don't do this.
Someone with mixed advice:
Jake Ginnivan says that I should always do this on COM objects that do not leave the scope of the method. If a COM object leaves the method scope, forget about it. Why can't I just forget about it all the time?
Paul Harrington's blog seems to suggest that MS's advice has changed once in the past. Is this the case when calling ReleaseCOMObject has become best practice, but no longer exists? Can I leave the finer details of MS memory management and assume that everything will be mostly beautiful?