Question How to add reference to another project?

Budius

Well-known member
Joined
Aug 6, 2010
Messages
137
Location
UK
Programming Experience
3-5
I'm assuming this is a pretty newbie question, but, as I couldn't find the answer on google or here, there you goes:

I've created a project and fill it up with all the re-usable bits I've created (a few object classes, some straight methods that just process what I've pass to them and returns)

now in a separate 'test' project I want to add the reference Import the namespace and use my functions and classes, but I couldn't manage to make vb.net Express 2010 to show any project under "add->reference->project tab"

I'm not keen to close it those down as a .dll cause I would like to be able to add more stuff on the fly...


thanks
 
To add a project reference first add the project to your solution (File > Add > Existing Project).
 
It doesn't sound to me like you should be referencing the project at all. Normally, you add multiple projects to the one solution when they are logically part of the same application and only that application. In your case, it sounds like you're creating a library of reusable types and members That you might want to use in any project. In that case, what you should do is leave the re-usable stuff in its own project in its own solution. Build your project and compile it to a DLL. You then reference that DLL directly in any other project that needs to use the functionality it contains. As far as your other projects are concerned, your re-usable component is a third-party product, so it's referenced like any other third-party product.
 
jmcilhinney,
I agree that most situations, specially big projects with several developers involved, that is the case.
But, I'm developing 3 small separate applications that all will use codes for accessing DB, connecting COMs ports, Bit wise processing, etc, therefore, to have both projects code open allows me to develop the main application and improve/debug the re-usable part at same time whilst keeping them coherent among the different applications.
But for sure in the future when the re-usable bits are working the way I want, I will close them down in a .dll.

Question:
whenever I "File > Add > Existing Project > Reusable stuff" and include it's reference in the proper application, will it compile the 'reusable stuff everytime it compiles the main application??

thanks for the replies.
 
Not in VB 2010, projects only rebuild if they are changed, so if main project is changed that is rebuilt, but if secondary (proj reference) isn't that is not rebuilt. I haven't tested this in VB 2008 that you're using.
 
Question:
whenever I "File > Add > Existing Project > Reusable stuff" and include it's reference in the proper application, will it compile the 'reusable stuff everytime it compiles the main application??
By default, yes.
 
Thanks for the answers.

Not in VB 2010, projects only rebuild if they are changed, so if main project is changed that is rebuild, but if secondary (proj reference) isn't that is not rebuilt. I haven't tested this in VB 2008 that you're using.
I would imagine it would be only if there are changes, just like everything else. But then it's just perfect for my situation.
and actually I'm on VB2010, I use .NET 3.5 to keep compatibility with XP < SP3.
 
You can reference another project within your solution.

As an example, create a new solution, call it MainProject. Save it. Now, use File, Add, New Project; call it LibraryProject. Save it.

Now you should have MainProject and LibraryProject listed in the Solution Explorer.

Right click on MainProject in the Solution Explorer and you should see Project Dependencies and Project Build Order. Set the MainProject to depend on the LibraryProject. Set the build order to build the LibraryProject first.

Right click MainProject again, select Add Reference. In the dialog you should see a tab for Projects, the LibraryProject should be listed.

You should be able to ref your library using File, Add , Existing Project. Follow the steps above for your library.

Regards
 
StoneCodeMonkey said:
Project Dependencies and Project Build Order
This is set automatically when you add project reference.
 
Back
Top