共用方式為


Working with Solution Items and Miscellaneous Items

Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions. For more information about upgrading, see FAQ: Converting Add-ins to VSPackage Extensions.

Most projects in Visual Studio are associated with a particular programming language or tool. Two project types, however, are not.

The Solution Items Project

The Solution Items project appears in Solution Explorer when you add an item to the solution, not to the integrated development environment (IDE) or a project. That is, when you right-click the solution and select New Item or Existing Item on the Add menu. Such items are associated with the solution itself and not with any project that happens to be in the solution.

The Solution Items project can contain any kind of file, and its contents are saved along with the solution. It might contain development notes, diagrams, implementation details, or other miscellaneous files you want to include with the solution but that do not fit into any specific project.

You can reference Solution Items by using Solution.Item(EnvDTE.Constants.vsSolutionItemsProjectUniqueName). If there are no solution items, then this statement fails. The UniqueName property returns "<SolutionFiles>" for this type of project.

The Miscellaneous Items Folder

Miscellaneous Items folder contains files that are not associated with a solution or its projects but that appear in Solution Explorer for your convenience. Miscellaneous Items is not really a project but rather a folder that is essentially a scratch pad service for Visual Studio that allows you to, for example, temporarily create a text document.

The Miscellaneous Items folder is always present in Solution Explorer, but it is hidden by default. You can choose to view it, however.

To view the Miscellaneous Items project

  1. On the Tools menu, click Options.

  2. Expand the Environment node in the left pane and click Documents.

  3. Select the Show Miscellaneous files in SolutionExplorer box.

If you display the Miscellaneous Files folder, you can also choose an option that specifies how many recently used miscellaneous files are restored to the Miscellaneous Files folder in Solution Explorer when you open the solution.

Normally, when the IDE is closed, the contents of the Miscellaneous Files folder are discarded unless you explicitly save the files. If you create a new file when no solution is open, a temporary one is created, but it is not persisted.

The UniqueName property returns "<MiscFiles>" for this type of project. You can reference the Miscellaneous Files folder by using Solution.Item(EnvDTE.Constants.vsMiscFilesProjectUniqueName).

Project properties and methods act on files in the Miscellaneous Files folder the same as regular project files, with the following exceptions:

Member Name

Difference

FileName property

Returns the empty string because this project has no project file.

UniqueName property

Returns the string "<MiscFiles>".

SaveAs method

This method fails (E_NOIMPL) because there is no file to write.

See Also

Tasks

How to: Add and Handle Commands

How to: Create an Add-In

Walkthrough: Creating a Wizard

Concepts

Automation Object Model Chart

Other Resources

Creating and Controlling Environment Windows

Creating Add-ins and Wizards

Automation and Extensibility Reference