Udostępnij za pośrednictwem


Don't Implement Package.ProjectPackage.Dispose. Use IVsHierarchy.Close instead

Should I implement IDisposable on my managed Package.ProjectPackage project node to release expensive resources?

No. Instead, put your resource cleanup code in the IVsHierarchy.Close method.

Implementing IDisposable on your project node may cause Visual Studio to call your ServiceContainer.Dispose method. This in turn calls the Dispose method of all service instances that implement IDisposable. Calling Dispose on a service instance that hasn't been removed first with ServiceContainer.RemoveService can cause exceptions.

Take a look at this and other notes like it in the new Frequently Asked Questions (FAQs) topics in our docs.

------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights