다음을 통해 공유


Package.ParseToolboxResource Method (TextReader, ResourceManager)

Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

‘선언
Protected Sub ParseToolboxResource ( _
    resourceData As TextReader, _
    localizedCategories As ResourceManager _
)
protected void ParseToolboxResource(
    TextReader resourceData,
    ResourceManager localizedCategories
)

Parameters

  • resourceData
    Type: System.IO.TextReader
    A text reader that provides toolbox item data in the format described in Remarks.
  • localizedCategories
    Type: System.Resources.ResourceManager
    A resource manager that provides localized lookup names for the categories provided in the resource data. This parameter can be null, in which case the category names are directly used.

Remarks

The text resource that a VSPackage parses using ParseToolboxResource must be embedded in an assembly and name space accessible to the VSPackage.

Text resources should be added to an assembly by right-clicking on the assembly's project, selection Add and the New Item. From the New Item menu, then select Text File. Once the text file has been added to the project, set its Build Action property to Embedded Resource.

This method can be used to add items to the toolbox automatically. The resource data is passed in through the resourceData parameter and consists of a text file with the following format:

; Comment
[CategoryName]
<class name>, <assembly name>

The category name can be localized through the localizedCategories resource manager that is passed into this method. The localizedCategories parameter may be null, in which case the category names are not localized.

The assembly name may either be a fully qualified name or a partial name. If a partial name is passed, the most recently accessed assembly with that partial name is loaded.

When processing assembly names, ParseToolboxResource, searches only directories specified in keys in the registry entry HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\AssemblyFolders, where <version> is the version number of the release of Visual Studio (for example, 8.0)

Note

The root path of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<Version> can be overridden with an alternate root when the Visual Studio shell is initialized, or use of DefaultRegistryRootAttribute. For more information see, Command-Line Switches (Visual Studio SDK) and DefaultRegistryRootAttribute.

The format of sub-keys under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\AssemblyFolders is

Name

Type

Data

Description

<FriendlyName>

REG_SZ

A string containing a fully qualified path to a directory which should contain assemblies used by Visual Studio.

The key's name, <FriendlyName>, may be any value so long as it is unique. The key's data contains the full path to a directory containing assemblies to be searched by ParseToolboxResource

Any VSPackage needing to use ParseToolboxResource must register itself with the Visual Studio environment as providing Toolbox items.

The attribute ProvideToolboxItemsAttribute must be applied to the VSPackage's implementation of Package. Depending on the implementation of the VSPackage ProvideToolboxFormatAttribute and ProvideToolboxItemConfigurationAttribute may also be required.

For more information on writing a Toolbox item provider, see Advanced Toolbox Control Development.

.NET Framework Security

See Also

Reference

Package Class

ParseToolboxResource Overload

Microsoft.VisualStudio.Shell Namespace