-1

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

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

“BAL.TaskBAL”不包含“deleteSelectedTaskBAL”的定义,并且找不到接受“BAL.TaskBAL”类型的第一个参数的扩展方法“deleteSelectedTaskBAL”(您是否缺少 using 指令或程序集引用?)
D​​: \Mohsin\CurrentlyWorking\ManageTaskBALDAL\AdminHomePage.aspx.cs

deleteSelectedBAL是新添加的方法

4

4 回答 4

0

在这里你可以尝试两件事

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

于 2012-12-17T06:59:13.880 回答
0

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

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

于 2012-12-17T10:40:30.010 回答
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]");

        }
    }

}
于 2013-08-21T17:45:46.343 回答
0

是对项目或作为项目构建工件的程序集的引用。如果您的参考是构建工件,那么您的依赖链就被破坏了。删除参考并添加项目参考

于 2013-08-21T17:54:03.290 回答