Projects and Solutions Frequently Asked Questions
This topic addresses questions from the Visual Studio SDK user community about projects and solutions. The topic will continue to be updated with new content from the community.
Contents
Identifying Files in the Solution to Persist Per-File Data
Q: I want to persist some display settings on a per-file basis. Since my settings are per-user, I assume it's best to write them to the .suo file. What is the best way to identify the files in the solution to write in the .suo file?
A: Yes, the best way to do this is to write your file settings to the .suo file. Identify the files in the solution by using the project reference (or, "projref") for the items, which you obtain by calling GetProjrefOfItem.
Using Standard Project Icons
Q: Is there a way I can reuse the icons Visual Studio shows in Solution Explorer for my own project types?
A: Yes. The managed package framework project base classes have support for the icons in Visual Studio. For more information, see Microsoft.VisualStudio.Package.ProjectNode.ImageName and Microsoft.VisualStudio.Package.FileNode.GetIconHandle(System.Boolean). The source code is in [Visual Studio SDK installation path]\VisualStudioIntegration\Common\Source\CSharp\Project and the IronPython project type in [Visual Studio SDK installation path]\VisualStudioIntegration\Samples\IronPythonIntegration\Project.
Releasing Resources Correctly
Q: Should I implement IDisposable on my ProjectPackage project node to release expensive resources?
A: No. Instead, put your resource cleanup code in the Close method. Implementing IDisposable on your project node may cause Visual Studio to call your Dispose method. This in turn calls the Dispose method of all service instances that implement IDisposable. Calling Dispose on a service instance that has not been removed with RemoveService can cause exceptions.