Cannot access a project's namespace in a solution

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 52
Reputation: Bhoot is an unknown quantity at this point 
Solved Threads: 1
Bhoot's Avatar
Bhoot Bhoot is offline Offline
Junior Poster in Training

Cannot access a project's namespace in a solution

 
0
  #1
May 10th, 2009
i am developing a visual studio solution that contains two projects.
Each project has its own namespace :
Project1 : namespace MainProject.Project1
Project2 : namespace MainProject.Project2

My problem is that i cannot access 2nd project's namespace in the 1st project and vice versa.
I tried to add the namespace through "using" statement :

  1. using namespace MainProject.Project2;

But, surprisingly, in Project1, the IntelliSense didnt even show me the Project2 namespace. Same was the case when i checked the other way round.

I think they should be accessible from each other because they are nested within the root namespace MainProject.

How do i solve this?
Bhoot
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Cannot access a project's namespace in a solution

 
0
  #2
May 10th, 2009
No, they shouldn't. You should add reference from Project1 to Project2 to be able to write using namespace MainProject.Project2; To add reference, from Project1 solution explorer references->add reference->browse to locate the project2 assembly or projects tab to get all assembles in all solution including project2 assembly.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 52
Reputation: Bhoot is an unknown quantity at this point 
Solved Threads: 1
Bhoot's Avatar
Bhoot Bhoot is offline Offline
Junior Poster in Training

Re: Cannot access a project's namespace in a solution

 
0
  #3
May 10th, 2009
Originally Posted by Ramy Mahrous View Post
No, they shouldn't. You should add reference from Project1 to Project2 to be able to write using namespace MainProject.Project2; To add reference, from Project1 solution explorer references->add reference->browse to locate the project2 assembly or projects tab to get all assembles in all solution including project2 assembly.
yaa..i tried that out.
But then its not letting me add references to both the projects saying that it would create a circular dependency.
How do i deal with that?
Bhoot
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Cannot access a project's namespace in a solution

 
0
  #4
May 10th, 2009
Yes, Just add reference from one to another not from both to both.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Cannot access a project's namespace in a solution

 
0
  #5
May 11th, 2009
The problem is both projects can't access one another. There is a compile order you can see (click the "Debug"/"Release" dropdown and select options at the bottom, its in there). It first compiles project A, then project B. But if it cannot compile Project A until Project B has been compiled, and Project B cannot be compiled until Project A has been compiled... you have circular dependencies.

All of the code that is common between the two assemblies must be moved to a third assembly, and your two existing projects can reference that assembly.

Also -- Be sure that when you add a reference for a project in the same solution that you click "Add Reference..." and at the top you will see tabs, click the "Projects" tab and add a reference to the project by name, not to the C:\location\of\the\dll.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 52
Reputation: Bhoot is an unknown quantity at this point 
Solved Threads: 1
Bhoot's Avatar
Bhoot Bhoot is offline Offline
Junior Poster in Training

Re: Cannot access a project's namespace in a solution

 
0
  #6
May 11th, 2009
Originally Posted by sknake View Post
The problem is both projects can't access one another. There is a compile order you can see (click the "Debug"/"Release" dropdown and select options at the bottom, its in there). It first compiles project A, then project B. But if it cannot compile Project A until Project B has been compiled, and Project B cannot be compiled until Project A has been compiled... you have circular dependencies.

All of the code that is common between the two assemblies must be moved to a third assembly, and your two existing projects can reference that assembly.

Also -- Be sure that when you add a reference for a project in the same solution that you click "Add Reference..." and at the top you will see tabs, click the "Projects" tab and add a reference to the project by name, not to the C:\location\of\the\dll.

ohk..i got it.
i will implement what you said. Infact , that would make my project easier to handle.
But, then wouldnt it affect the namespaces i have already structured?
Or just refactoring the namespaces and changing the default namespace in the projects would work out?
Also then my structure would be as follows :
  1. namespace NetworkTracker
  2. {
  3. // types common to both the other assemblies (or projects).
  4. // i would create this in a project named NetworkTrackerCommon.
  5.  
  6. namespace Tracker
  7. {
  8. // client-side code
  9. // i will include this namespace in client-side assembly : Tracker
  10.  
  11. }
  12.  
  13. namespace UserInterface
  14. {
  15. // server-side code
  16. // i would include this namespace in server-side assembly : UserInterface
  17. }
  18. }

What should i keep the default namespaces in each of the assemblies ?
I think it should be :
NetworkTracker in NetworkTrackerCommon assembly
NetworkTracker.Tracker in Tracker assembly
NetworkTracker.UserInterface assembly

I would also refactor the names in their respective assemblies.

Am i right? Or i should keep the root namespace NetworkTracker as the default namespace in all of the projects ? ( i didnt seem this feasible).
Bhoot
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Cannot access a project's namespace in a solution

 
0
  #7
May 11th, 2009
As far as moving code around, just refactor it like you mentioned. I don't see why you would having a nested namespace like you posted, though. And as far as mentioning what code goes in what assembly I couldn't tell you without knowing your project a little better. Here is an example of a project I have that includes an ASP.NET website and a .NET Windows form application that share a common BLL (business logic) and DAL (data access).

  1. Project.Web - Website (refs .core, .data, .extensions, .merchants)
  2. Project.Core - BLL (refs .data, .desktop, .merchants, .extensions)
  3. Project.Data - DAL (refs .extensions)
  4. Project.Desktop - .NET Form App (refs .core, .data. .extensions)
  5. Project.Extensions - 3.5 Extensions (no refs)
  6. Project.Merchants - Online merchant stuff (refs .extensions)

I hope that makes sense and helps in your decision making. If you still have questions then post the function of each assembly you have, or think you should have, and we'll go from there.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 52
Reputation: Bhoot is an unknown quantity at this point 
Solved Threads: 1
Bhoot's Avatar
Bhoot Bhoot is offline Offline
Junior Poster in Training

Re: Cannot access a project's namespace in a solution

 
0
  #8
May 11th, 2009
Originally Posted by sknake View Post
As far as moving code around, just refactor it like you mentioned. I don't see why you would having a nested namespace like you posted, though. And as far as mentioning what code goes in what assembly I couldn't tell you without knowing your project a little better. Here is an example of a project I have that includes an ASP.NET website and a .NET Windows form application that share a common BLL (business logic) and DAL (data access).

  1. Project.Web - Website (refs .core, .data, .extensions, .merchants)
  2. Project.Core - BLL (refs .data, .desktop, .merchants, .extensions)
  3. Project.Data - DAL (refs .extensions)
  4. Project.Desktop - .NET Form App (refs .core, .data. .extensions)
  5. Project.Extensions - 3.5 Extensions (no refs)
  6. Project.Merchants - Online merchant stuff (refs .extensions)

I hope that makes sense and helps in your decision making. If you still have questions then post the function of each assembly you have, or think you should have, and we'll go from there.
yaaa...i got it.
you are right.I wont make a nested namespace.
I will go as follows :
NetworkTracker.Common - the assembly containing the common code.
NetworkTracker.Tracker namespace for the client-side assembly.
NetworkTracker.UserInterface namespace for the server-side assembly.

thank you.
Bhoot
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC