Udostępnij za pośrednictwem


How to: Package and Install Custom Controls for the Toolbox

Visual Studio includes many Toolbox controls. If these controls do not meet your needs, you can search for additional controls online or create your own custom controls for use in Visual Studio. 

Note

The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, click Import and Export Settings on the Tools menu. For more information, see Working with Settings.

Packaging Controls for Installation through the Visual Studio Content Installer

After you have created a custom control, you can package it in a .vsi file so that other developers can install it by using the Visual Studio Content Installer. The Content Installer only recognizes .vsi files. A .vsi file is a compressed file that contains the .dll file for the control and an XML-based definition file that must have the file name extension .vscontent. 

To create a .vscontent file

  1. On the File menu, point to New and then click File.

  2. In the General category, select XML File and then click Open.

  3. Create a valid .vscontent file for the Toolbox control by using the Visual Studio Content Installer Schema Reference.

    For example:

    <VSContent xmlns="https://schemas.microsoft.com/developer/vscontent/2005">
        <Content>
            <FileName>MyButtonControl.dll</FileName>
            <DisplayName>My Custom Button</DisplayName>
            <Description>A control created for this example.</Description>
            <FileContentType>Toolbox Control</FileContentType>
            <ContentVersion>2.0</ContentVersion>
        </Content>
    </VSContent>
    
  4. Save the .vscontent file in the same directory as the .dll file for the control.

After you have created the .vscontent file, you can package it together with the .dll file for the control by creating a .vsi file that will be recognized by the Visual Studio Content Installer. You can distribute the .vsi file to other developers if you want to.

To create a .vsi file

  1. In Windows Explorer, select the .dll file for the custom control and the associated .vscontent file that you created.

  2. Right-click the selected files, click Send To, and then click Compressed (zipped) Folder.

    The selected files are compressed together into a .zip file.

  3. Rename the file name extension of the .zip file to .vsi. You can also rename the file if you want to.

    You can now distribute the control to others by using e-mail, the Web, a network share, or other method.

Installing a Control That is Packaged in a .Vsi File

After you have located a control that has been packaged as a .vsi file, you can easily install the control for use in Visual Studio.

To install a custom control packaged in a .vsi file

  1. Double-click the .vsi file.

    The Visual Studio Content Installer appears.

  2. On the Select Content to Install page, select the items that you want to install and then click Next. If the component is not signed, a warning might appear.

Note

It is highly recommended that you read the information in Publisher Status to determine whether the control is signed. For additional security, click Review to display a list of the files that will be installed on your computer.

  1. On the Content Installation page, click Finish to install the control.

    If Visual Studio is not currently open, the installer will open and then close Visual Studio during the installation process.

  2. Click Close to exit the installer.

    The control will appear in the My Controls section of the Toolbox.

See Also

Reference

Visual Studio Content Installer Schema Reference

Other Resources

Community Component Essentials