Yang
Yang

Reputation: 8711

Include (namespace) file outside of project folder

There's a following directory structure:

inetpub:

 - Cms
   - Board
   - Core
   - Data
      - ViewModels
        - UserView.cs
   - Design
   - Linkage
   - CMSContent
   - MJBank
   - OuterDLL
   ...
   - Web
     - Cms.Admin
       - Controllers

     - Cms.Web
       - Controllers
       ...
 - wwwroot

For example, inside the file \inetpub\Cms\Web\Cms.Admin\Controllers\UserController.cs I've got a top statement:

using Cms.Data.ViewModels;

...

public string start()
{
      UserView uv = new UserView(); // Error: The type or namespace can not be found
}

...

i.e I want to include a file that is located outside of the project folder and it throws an error that it can't find such class.

Is there a way to instruct Visual Studio to find files outside of project folder?

Upvotes: 1

Views: 908

Answers (1)

Jaro
Jaro

Reputation: 33

From what it seems like you are trying to do, is reference a project.

So, expand the project, where you will be writing your using namespace statement.

Right-click references => Add Reference => Projects => 'The project, where the other file is contained'

Now, it should find your namespaces just fine.

Have a look at this : Add project references

Upvotes: 1

Related Questions