This documentation is archived and is not being maintained.

Troubleshooting Broken References

If your application attempts to use a broken reference, an exception error is generated. The inability to find the referenced component is the primary trigger for the error, but there are several situations in which a reference can be considered broken. These instances are shown in the following list:

  • The project's reference path is incorrect or incomplete.
  • The file being referenced has been deleted.
  • The file being referenced has been renamed.
  • The network connection or authentication has failed.
  • The reference is to a COM component that is not installed on the computer.

The following are remedies to these problems.

Note   Files in assemblies are referenced with absolute paths in the project file. Because of this, it is possible for users working in a multideveloper environment to be missing a referenced assembly in their local environment. To avoid these errors, it is better in these cases to add project-to-project references. For more information, see Adding and Removing References and Programming with Assemblies.

Reference Path Is Incorrect

If projects are shared on different computers, some references might not be found when a component is located in a different directory on each computer. References are stored under the name of the component file (for example, MyComponent). When a reference is added to a project, the folder location of the component file (for example, C:\MyComponents\) is appended to the Reference Path project property.

When the project is opened, it attempts to locate these referenced component files by looking in the directories on the reference path. If the project is opened on a computer that stores the component in a different directory, such as D:\MyComponents\, the reference cannot be found and an error appears in the Task List.

To fix this problem, you can delete the broken reference and then replace it using the Add Reference dialog box. Another solution is to use the Reference Path item in the project's property pages and modify the folders in the list to point to the correct locations. The Reference Path property is persisted for each user on each computer, so modifying your reference path does not affect other users of the project.

Tip   Project-to-project references do not have these problems. For this reason, use them instead of file references, if possible. For more information, see Components and Assemblies.

To fix a broken project reference by correcting the reference path

  1. In Solution Explorer, right-click your project node and choose Properties from the shortcut menu.
  2. Select the appropriate property page in the dialog box.
    • If you are using Visual Basic, select Reference Path under the Common Properties folder in the left pane. In the Reference Path pane, type the path in the Folder field, and then click the Add Folder button.

      -or-

    • If you are using Visual C#, select References Path under the Common Properties folder in the left pane. Click in the large edit box to get an edit point, and then type the path to the folder that contains the item you want to reference and click OK.

Referenced File Has Been Deleted

It is possible that the file being referenced has been deleted and no longer exists on the drive.

To fix a broken project reference for a file that no longer exists on your drive

Referenced File Has Been Renamed

It is possible that the file being referenced has been renamed.

To fix a broken reference for a file that has been renamed

  • Delete the reference, and then add a reference to the renamed file.
    Tip   If the reference exists in another location on your computer, you need to read it in from that location. For more information, see Adding and Removing References.

Network Connection or Authentication Has Failed

There can be a variety of causes for inaccessible files: a failed network connection or a failed authentication, for example. Each cause might have a unique means of recovery; for example, you might need to contact your local administrator for access to the required resources. However, deleting the reference and fixing the code which used it is always an option. For more information, see Adding and Removing References.

COM Component Is Not Installed on Computer

If a user has added a reference to a COM component and a second user attempts to run the code on a computer that does not have this component installed, the second user will receive an error that the reference is broken. Installing the component on the second computer will correct the error. For more information about using references to COM components in your projects see COM Interoperability in Visual Basic and Visual C#.

See Also

Referencing Namespaces and Components | Managing Projects | Adding and Removing References | Add Reference dialog box | Reference Path

Show: