How to: Add a Component Reference to a Visual Studio Web Project

In a Visual Studio Web project, you can reference .NET components that are in the global assembly cache (GAC) or COM components registered on your computer. You can also reference components that are located on your hard drive but not in the GAC. Referencing a component makes it available to use in your code.

Note Note

If you deploy an application that contains a reference to a custom component that is registered in the GAC, the component will not be deployed with the application. To deploy any assembly with your application, you must manually add the assembly to the application's Bin folder. For more information, see Working with Assemblies and the Global Assembly Cache and Deployment and the Global Assembly Cache.

To add references to registered COM components

  1. On the Website menu (for Web site projects), or the Project menu (for Web application projects) choose Add Reference and then click the COM tab.

  2. Select the component you want to use from the list of COM components and then click OK.

    Visual Studio automatically creates an interop assembly, which is a specialized .NET Framework assembly that contains metadata to define COM types and that enables .NET Framework compilers to resolve calls to COM objects.

    If you don't see the component you want, click the Browse tab and look for the component file on your hard drive.

To add references to .NET components that are already registered with the .NET Framework

  1. On the Website menu (for Web site projects), or the Project menu (for Web application projects) choose Add Reference and then click the .NET tab in the dialog box.

  2. Select the component you want to use from the list of .NET components and then click OK.

    If you don't see the component you want, click the Browse tab and look for the assembly file on your hard drive.

To use a referenced component

Show: