How to reference solution items in a multiproject solution

pssdn

Member
Joined
Mar 8, 2011
Messages
5
Programming Experience
5-10
New to VB.Net, but not to VB programming.
In VS2010 I want to include several modules, classes and usercontrols as shared components in the "Solution items" folder.
This is a solution that has several projects on it.
Then, in the projects I want to use the routines and classes, but when I use those rutines the compiler does not find the references.
After searching the documentation, I can not find a way to do it, how is this done ?
 
In Solution Explorer you can use context menu on the project item you want to add reference for, use the 'Add reference' choice and in the dialog choose the project to reference in the Projects tab.
It can also be done by selecting the project node in Solution Explorer, and use the Project menu option 'Add reference'.
The references dialog is yet also available from the References page in project properties.

Once you have added the reference you can use its types either by fully qualifying them by namespace, or use the Imports statement to import the namespace to a code file. Namespace imports can also be done globally for the project in the mentioned References page in project properties.
 
As I can see, in the Solution Explorer, 'Add reference' is only available for the contextual menu of projects.

In the appearing dialog box, the only references I can add are those of the other projects, but does not apear the items inside 'Solution items'.

To clarify, here is a diagram of what I have.
VB.NET:
Solution 'MyBigProject'
   Solution items
      modUtils
      clsInvoice
   ProjectA
      Forms and items for project A....
   Project B
      Forms and items for project B...

What I want is to share a single copy of modUtils and clsInvoice between all the projects of the solution, and use the modUtils routines and clsInvoice class inside ProjectA and ProjectB
 
I see, managing solution items (in Solution Explorer) is not possible for the VB Express I'm using, so I will have to make a qualified guess. For a project you can 'add existing item' and browse to the item, then click the 'Add' button dropdown and choose 'add as link'. Now the item is compiled as part of the project, ie no reference, and you can use it as such, but editing it is done in the central file. Maybe in your VS edition you can make that link by other means, but that is how it should be set up.
 
Back
Top