Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:17:06+00:00 2026-06-09T19:17:06+00:00

So i have a program that is a 3 tiers program, the UI, the

  • 0

So i have a program that is a 3 tiers program, the UI, the BLL (Business Logic Layer) and of course the DAL (Data Access Layer). The UI always speaks to the BLL of which uses the DAL to retrieve data units, assembling them in a format and returning them to the UI.

Since this is for my job i want to make sure that conventions are ALWAYS used (not a big fan of everyone programming their own style wherever they want!). So i thought it would be nice to have something like this.

using (Bll.MyService service = new Bll.MyService()) {
    //My Sweet Code
} 

BUT!!! If the Bll is located in a namespace that my UI is not, this will not be an option. Here is a more lenghty example of what i mean.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyApp;

//Entry point
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //I want to be able to do a using MyApp and access the Bll objects!
            Bll.ApiService service = new Bll.ApiService(); //ERROR LINE
        }
    }
}

//Data access layer
namespace MyApp.DAL
{
    class ApiDataAccessor
    {
        public int MyVar = 1;
    }
}

//The bacon letuce layer of course
namespace MyApp.Bll
{
    class ApiService
    {
        public void MyFunction()
        {
            //todo: make more awesome
        }
    }
}

If anyone has any suggestions that would be great! Thanks!

EDIT:

Added the //ERROR LINE to a comment in the code so to make the error obvious. I also found a hack. using Bll = MyApp.Bll which will enforce the Bll.ApiService to be used. I do not know if i like this solution (as it easy to mess up and be angry until i realize that i did not alias the namespace).

EDIT (Again):

There are a few solutions.

  1. using Bll = MyApp.Bll at the top and then all objects in that namespace have to be referenced with Bll.MyObject which is what we wanted!

  2. Require fully qualified names. MyApp.Bll.MyObject. Which is what we did not want (as it can get verbose with large namespaces)

  3. Just include the namespace up top. using MyApp.Bll.

In summary, we were hoping to get using MyApp in some way to allow us to reference all those namespaces and their objects like Bll.ThisObject and Dal.ThatObject but instead, if that were a solution desired, the only way to accomplish that would be to include 2 using statements, which are aliased. using Dal = MyApp.Dal and using Bll = MyApp.Bll

Thanks everyone for your help.

Here is the solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyApp;
using Bll = MyApp.Bll;

//Entry point
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //I want to be able to do a using MyApp and access the Bll objects!
            Bll.ApiService service = new Bll.ApiService(); // <-- it works.
        }
    }
}

//Data access layer
namespace MyApp.DAL
{
    class ApiDataAccessor
    {
        public int MyVar = 1;
    }
}

//The bacon letuce layer of course
namespace MyApp.Bll
{
    class ApiService
    {
        public void MyFunction()
        {
            //todo: make more awesome
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:17:07+00:00Added an answer on June 9, 2026 at 7:17 pm

    I think the confusion lies here: you don’t have a namespace called Bll. You have a namespace called MyApp.Bll.

    Regardless of having a using MyApp directive, you need to either add a using MyApp.Bll directive and then just reference ApiService directly in your code, or fully-qualify the class as MyApp.Bll.ApiService.

    If all you’re after is the ability to refer to the MyApp.Bll namespace with the symbol Bll, you can alias the namespace:

    using Bll = MyApp.Bll

    Also, based on comments on the question and various answers, it’s worth pointing out that the using statement, which provides a convenient way to declare and clean up unmanaged resources, and appears as a block in your code is not the same as the using directive that imports namespaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a program that has 3 classes of which 2
I have a program that starts constantly juggles between 3 separate timers. The main
I have program that requires Python 3, but I develop Django and it uses
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
I have a program that gets a JSON from the server using getJSON and
I have a program that saves an image in a local directory and then
I have a program that reads from a file that grabs 4 bytes from
I have a program that encrypts files, but adds the extension .safe to the
I have a program that I want to distribute, without giving the source code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.