简体   繁体   中英

I have one solution with 3 projects, the build order is fine, but dependencies not loading other namespaces

I have 3 projects in 1 solution file.

  • Solution: James
    • Project: James.Domain (class library)
    • Project: James.UnitTests (Test project)
    • Project: James.WebUI (MVC project)

I have ticked the dependencies and the build order seems fine. When I try to access James.Domain namespace from within a James.WebUI.Controllers namespace, It cannot see the Domain.

Must I do something else to add the dependencies?

Project: James.Domain
Entities folder

namespace James.Domain.Entities
{
    public class User
    {
        public int Id;
        public string Username;
        public string Email;
    }
}

Project: James.WebUI
Controllers folder

using James.Domain.Entities; // Errors

namespace James.WebUI.Models
{
    public class DashboardController : Controller
    {
        public DashboardController(repo)
        {

        }

        [Authorize(Roles="Admin")]
        public ActionResult Index()
        {
            return View();
        }
    }
}
  • The Domain project does not depend on anything,
  • The UnitTests project relies on both Domain and WebUI
  • The WebUI relies on the Domain project
  1. Right-click on your WebUI project
  2. Select "Add Reference"
  3. Under the "Solution" tab you can select your Domain project...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM