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 :

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?

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.

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?

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.

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 :

namespace NetworkTracker
{
    // types common to both the other assemblies (or projects).
    // i would create this in a project named NetworkTrackerCommon.

    namespace Tracker
    {
         // client-side code
         // i will include this namespace in client-side assembly : Tracker

    }

    namespace UserInterface
    {
        // server-side code
        // i would include this namespace in server-side assembly : UserInterface
     }
}

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).

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).

Project.Web - Website (refs .core, .data, .extensions, .merchants)
Project.Core - BLL (refs .data, .desktop, .merchants, .extensions)
Project.Data - DAL (refs .extensions)
Project.Desktop - .NET Form App (refs .core, .data. .extensions)
Project.Extensions - 3.5 Extensions (no refs)
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.

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).

Project.Web - Website (refs .core, .data, .extensions, .merchants)
Project.Core - BLL (refs .data, .desktop, .merchants, .extensions)
Project.Data - DAL (refs .extensions)
Project.Desktop - .NET Form App (refs .core, .data. .extensions)
Project.Extensions - 3.5 Extensions (no refs)
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. :)

This question has already been answered. Start a new discussion instead.