Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three Visual Studio solutions. One solution/project (Project1) defines an interface (IChokable, say). The second solution/project (Project2) contains a a class which creates an object (fooChicken) which implements IChokable. So Project2 has to have a reference to Project1, I get that.

In a third solution/project (Project3), I create a fooChicken object. So Project3 must contain a reference to Project2, I get that.

HOWEVER - this won't compile. It complains that Project3 must ALSO contain a reference to Project1, even though Project3 never tries to access any of the elements of IChokable on the fooChicken object.

Am I just doing this wrong? Do I really have to have a reference in every project to every project referenced by every other project? This strikes me as wrong. And not really doable. What if the app from Project3 existed in the world already, and I updated the objects from Project2 to contain new references, and shipped them? Would those Project3 objects stop functioning?

Surely I am missing something here. Is this just a debugging preference by Visual Studio?
Posted
Comments
Prasad Avunoori 26-Jun-14 0:32am    
Do you have 3 solutions? or 1 solution with 3 projects?
JoeRip 26-Jun-14 0:46am    
Actually, 2 solutions: 1 with Project 1, and 1 with Projects2 and 3. I started to break the third project out to see if that mattered, but got distracted... why?

1 solution

You must have to add the dependencies of Project 2 (that mean Project 1) in order to work with it. Since project 2 has definition of fooChicken but it uses/implements interface (IChokable) defined in project 1 so you need to add it to Project 3.

There is nothing wrong here, it is simple and we encounter it very often, to use any DLL we must add all of its dependencies.

When you create a DLL...it is extremely important that you identify exactly what dependencies your application requires, and their versions. You must provide details of the dependencies in metadata of DLL or in read me file (instructions/ how to use).

For a real life example, please have a look at below link (and for more dig into the codebase of Microsoft Enterprise Library).
http://msdn.microsoft.com/en-us/library/ff647601.aspx[^]

Hope this will help. Thanks.
 
Share this answer
 
v3
Comments
JoeRip 26-Jun-14 0:50am    
If you don't have the code for a DLL, how do you see it's dependencies? If I didn't own the DLL that creates fooChicken, how would I know that it required the DLL that creates the IChokable interface?
Snesh Prajapati 26-Jun-14 0:59am    
When you create a DLL...it is extremely important that you identify exactly what dependencies your application requires, and their versions. You must provide details of the dependencies in metadata of DLL or in read me file (instructions/ how to use). This is how people do in general.
Snesh Prajapati 26-Jun-14 1:06am    
Please have a look at http://msdn.microsoft.com/en-us/library/ff647601.aspx for a real time example. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900