locked
Three Layer Architecture RRS feed

  • Question

  • User2045484789 posted

    Hello everyone

    I'm a newbie and I'm watching a video tutorial about designing an online-shop with "Three Layer Architecture" method. So I created two other projects (named BL and DL) parallel to the main project, as you can see in the following picture:

    when I open the main form (Default.aspx) and double click on it, the form load (Default.aspx.cs) opens, but when I want to add "using BL;", "using BL" is not in the list by default:

    Thanks for help.

    Monday, August 14, 2017 12:48 PM

All replies

  • User1068175894 posted

    you need to add a reference from your main project to the BL project, right click the project where it says references and add the reference to BL and DL.

    By the way 3 layers architecture is not current any more, take a look to domain driven design and onion architecture

    Monday, August 14, 2017 1:32 PM
  • User2045484789 posted

    Thanks for your reply.

    According to the tutorial, I right-clicked on my project and added reference (DA and BL) to it and I've added DA to BL's reference, but I don't know what's the problem!

    Thanks for your Suggestions, I'll try to learn them in the future.

    Monday, August 14, 2017 2:13 PM
  • User1771544211 posted

    Hi Payman9272,

    when I open the main form (Default.aspx) and double click on it, the form load (Default.aspx.cs) opens, but when I want to add "using BL;", "using BL" is not in the list by default:

    The BL is another project inside this solution, you can't using the BL namespace directly in your project directly. To use the BL namespace you need to add the reference of the BL project inside your project. This behavior is by design.

    When you add the reference of the BL project, the following items are added into your project's bin folder. So then you add the  using BL in your project.

    • A copy of the assembly created from the added project.
    • Copies of dependent assemblies, XML document files, license files, resource files, and so on.

    Best Regards,

    Jean

    Tuesday, August 15, 2017 1:36 AM
  • User2045484789 posted

    Thanks for your help

    I went through the following steps:

    1-I clicked add reference:

    2-Checked "DA" and "BL" and selected OK:

    But I can use namespace "DA" directly in my project, so why can't I use "BL" directly?

    And here is my bin:

    Tuesday, August 15, 2017 7:18 AM
  • User1771544211 posted

    Hi Payman9272,

    But I can use namespace "DA" directly in my project, so why can't I use "BL" directly?

    It seems that you have already add the reference to DA and BL in your web project. That's strange that you can't add using of the BL.

    Is there any error when build the BL project?  What message does the Visual Studio show when you add the using of BL? Please try rebuild your solution after you add the using of BL.

    Best Regards,

    Jean

    Tuesday, August 15, 2017 8:02 AM
  • User2045484789 posted

    Here is one of the errors:

    Tuesday, August 15, 2017 10:07 AM
  • User1120430333 posted

    Here is one of the errors:

    The UI project is to only have reference to the BL, the BL has reference to the DL.

    N-tier is n-tier that can be implemented at the Windows or Web UI(s).  N-tier implements SoC.

    https://en.wikipedia.org/wiki/Separation_of_concerns

    This also implements SoC or SoD.

    https://www.codeproject.com/Articles/228214/Understanding-Basics-of-UI-Design-Pattern-MVC-MVP

    http://www.c-sharpcorner.com/UploadFile/SukeshMarla/building-Asp-Net-applications-using-mvp-architectu-part-1/

    https://msdn.microsoft.com/en-us/library/bb384398.aspx

    I suggest that you step back and understand n-tier with a simple example.

    https://www.codeproject.com/Articles/36847/Three-Layer-Architecture-in-C-NET

    Tuesday, August 15, 2017 11:13 PM
  • User1068175894 posted

    Your references are fine, the problem is your BL_Default class is private, therefore it cannot be accessed from other projects

    You can solve the issue by making your class public:

    public class BL_Default{
    ...



    Wednesday, August 16, 2017 2:50 AM