asp.net中的三层架构问题

时间:2012-12-17 06:49:00

标签: c# asp.net

我有一个三层架构的asp.net项目。我在解决方案中添加了一个业务访问层(BAL)和数据访问层(DAL)作为类库,我在BAL中添加了DAL的引用,并在UI中添加了BAL的引用。

我已经在其中一个BAL类中编写了一些方法,并且它工作正常,但现在我正在向任何类的BAL添加新方法并在UI中访问新添加的方法。因此,在UI中无法访问新添加的方法,并且它给出了错误

  

'BAL.TaskBAL'不包含。的定义   'deleteSelectedTaskBAL'并没有扩展方法   'deleteSelectedTaskBAL'接受第一个类型的参数   可以找到'BAL.TaskBAL'(你是否错过了使用指令或者   装配参考?)
  d:\穆赫辛\ CurrentlyWorking \ ManageTaskBALDAL \ AdminHomePage.aspx.cs

此处deleteSelectedBAL是新添加的方法

4 个答案:

答案 0 :(得分:0)

在这里你可以尝试两件事

1)从UI文件夹的bin中删除.dll文件,然后再次尝试添加。 2)您可以通过右键单击解决方案来设置项目依赖性。然后你不需要一次又一次地添加

答案 1 :(得分:0)

我过去曾遇到过这个问题。有时清理和重建BAL项目也有帮助。

还要确保在调用方法的代码文件中使用命名空间。

答案 2 :(得分:0)

namespace BLL
{
    public class tblSubCategory
    {
        public tblSubCategory()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        private int iSubCatId;
        private string sSubCatName;
        private string sImagePath;
        private int iCategoryId;
        private string sDescription;
        private decimal decPrice;
        private int sCategoryName;

        public int SubCatId
        {
            get
            { return iSubCatId; }
            set
            { iSubCatId = value; }
        }
        public string SubCatName
        {
            get
            {
                return sSubCatName;
            }
            set
            { sSubCatName = value; }
        }
        public string ImagePath
        {
            get
            {
                return sImagePath;
            }
            set
            { sImagePath = value; }

        }
        public int CategoryId
        {
            get
            {
                return iCategoryId;
            }
            set
            { iCategoryId = value; }
        }
        public string Description
        {
            get
            { return sDescription; }
            set
            { sDescription = value; }
        }
        public decimal Price
        {
            get
            { return decPrice; }
            set
            { decPrice = value; }
        }
        public int CategoryName
        {
            get
            {
                return sCategoryName;
            }
            set
            { sCategoryName = value; }
        }

        public int InserttblSubCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@sSubCatName", sSubCatName);
            db.AddParameter("@sImagePath", sImagePath);
            db.AddParameter("@iCategoryId", iCategoryId);
            db.AddParameter("@sDescription", sDescription);
            db.AddParameter("@decPrice", decPrice);
            return db.ExecuteNonQuery("[tblSubCategory_Insert]", true);
        }
        public DataSet SelectAlltblSubCategory()
        {
            DBAccess db = new DBAccess();
            //db.AddParameter("@iSubCatId", iSubCatId);
            //return db.ExecuteDataSet("tblSubCategory_SelectAllForDDL");
            return db.ExecuteDataSet("tblSubCategory_SelectAll");
        }
        public int UpdatetblSubCategory()
        {
            DBAccess db = new DBAccess();

            db.AddParameter("@iSubCatId", iSubCatId);
            db.AddParameter("@sSubCatName", sSubCatName);
            //db.AddParameter("@sImagePath", sImagePath);
            //db.AddParameter("@iCategoryId", iCategoryId);
            db.AddParameter("@sDescription", sDescription);
            db.AddParameter("@decPrice", decPrice);
            return db.ExecuteNonQuery("[tblSubCategory_Update]", true);
        }
        public int DeletetblSubCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iSubCatId", iSubCatId);

            return db.ExecuteNonQuery("[tblSubCategory_Delete]", true);
        }
        public DataSet SubCategoryAscByCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", CategoryId);

            return db.ExecuteDataSet("[tblSubCategory_SelectAsc]");

        }
        public DataSet SubCategoryDescByCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", CategoryId);

            return db.ExecuteDataSet("[tblSubCategory_SelectDescPrice]");

        }
        public DataSet InnerjointblSubCategory1()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", CategoryId);

            return db.ExecuteDataSet("[tblSubCategory_InnerJoin1]");

        }
        public DataSet SelectDesctblSubCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);
            //db.AddParameter("@sSubCatName", sSubCatName);
            return db.ExecuteDataSet("tblSubCategory_SelectDesc");
        }
        public DataSet SelectSubCatName()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);

            return db.ExecuteDataSet("tblSubCategory_SelectSubCatName");
        }
        public DataSet SelectProductsBySubCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iSubCatId", iSubCatId);

            return db.ExecuteDataSet("tblProduct_ProductBySubCat");
        }

        public DataSet selectallsub()
        {

            DBAccess db = new DBAccess();
            //db.AddParameter("@iSubCatId", iSubCatId);
            //return db.ExecuteDataSet("tblSubCategory_SelectAllForDDL");
            return db.ExecuteDataSet("tblSubCategory_InnerJoin2");
        }
        public DataSet selectallsubasc()
        {

            DBAccess db = new DBAccess();
            //db.AddParameter("@iSubCatId", iSubCatId);
            //return db.ExecuteDataSet("tblSubCategory_SelectAllForDDL");
            return db.ExecuteDataSet("tblSubCategory_InnerJoinDesc");
        }
        public DataSet SelectSubCategoryBySubCatId()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iSubCatId", iSubCatId);

            return db.ExecuteDataSet("tblSubCategory_ddlProduct");
        }

        public DataSet SelectSubCategoryByCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);

            return db.ExecuteDataSet("tblSubCategory_SelectSubCategoryByCategory");
        }
        public DataSet GetSubCategory()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@sSubCatName", sSubCatName);

            return db.ExecuteDataSet("tblSubCategory_SelectSname");
        }
        public DataSet SubCategoryByCatAsc()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);

            return db.ExecuteDataSet("tblSubCategory_asc");
        }
        public DataSet SubCategoryByCatDesc()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);

            return db.ExecuteDataSet("tblSubCategory_desc");
        }
        public DataSet CategoryByCatId()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCategoryId", iCategoryId);

            return db.ExecuteDataSet("tblCategory_SelectAllCat");
        }
        public DataSet InnerjointblSubCategoryTop3()
        {
            DBAccess db = new DBAccess();
            //db.AddParameter("@sCategoryName", CategoryName);
            db.AddParameter("@iCategoryId", CategoryId);
            return db.ExecuteDataSet("[tblSubCategory_InnerJoinTop3]");

        }
    }

}

答案 3 :(得分:0)

是对项目程序集的引用,它是项目的构建工件。如果您的引用是构建artificate,那么您的依赖关系链就会被破坏。删除引用并添加项目引用