Share Files Between VB.Net Projects

If you've tried to add a file, or resource, to a VB.Net project from a directory outside the main project directory, you'll have found that a new version of the file is copied into the main project directory.
I keep my constants organised in separate files. Some, such as database field names or lengths applying to more than one project. So I make a _Shared directory and put the .vb files in there, and add a link into the project instead.

Select Add Existing Item from the Project menu. Browse to your shared direcory, choose your file, the select Link File instead of Open, from the dropdown button. This applies to Visual Studio 2003, but I believe it's Add As Link in newer versions.

Add Shared Link File In VB.Net Project

Then, if you had two projects open linking to the same file, and you change the file in one project, the other project will warn you about the changes and ask if you want to re-load the file. (This happens by default, unless you change some settings).

Modified Outside Editor
Page Updated 02/02/09