Referencing folders created in the project

4

After I go to Project > Add > New Folder, rename the folder and put classes inside it I can no longer reference it in another file, for example if it were to be used in a controller , I would use as always I used the

using nomeProjeto.NomedaPasta

However, this "NomedaPasta" does not appear and even putting it without the help of VS, when I use the controler that has the reference, an exception is generated saying namespace is invalid.

I've tried everything, close and open VS, close all VS tabs and reopen, clean temporary file, reboot machine ...

    
asked by anonymous 21.12.2015 / 14:08

2 answers

5

I may be wrong but I think you are not fully understanding what you have to use in this using . It refers to namespace , not to projects and folders.

To use classes that are in nomeProjeto.NomedaPasta , they must be inside a block like this:

namespace nomeProjeto.NomedaPasta {
    //classes aqui
}

But it's probably not what you want. Do not mix namespaces with folders and projects, they are different things. These namespaces should organize the code. Visual Studio organizes the project. These are things that have no direct relation.

I can not suggest a more suitable name for namespace because I do not know the nature of the software and the structure of the code.

More information about the subject . Other ask about this .

    
21.12.2015 / 14:13
2

I think there is a confusion of concepts there.

This:

using nomeProjeto.NomedaPasta

Indicates the use of a namespace , not a directory.

What Visual Studio does for you (for convenience, incidentally) is, when creating a class in a directory, assign a namespace to the class based on the directory name. So much so that nothing prevents you from creating a class inside a directory with another namespace . It will work the same.

    
21.12.2015 / 14:13