在我的bllLanguage.cs
课程中,我无法创建dalLanguage
课程的对象,反之亦然。它说无法找到dalLanguage.cs
/ bllLanguage.cs
。
以下代码有什么问题?
bllLanguage.cs
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Collections;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Proj2;
namespace Proj2.BLL.Main.Setting
{
public class bllLanguage
{
public bllLanguage()
{
//add constructor code here
}
#region Properties
/// <summary>
/// Properties
/// </summary>
private int intLanguageID;
private string strDescription;
private string strValue;
#endregion
public int LanguageID
{
get { return intLanguageID; }
set { intLanguageID = value; }
}
public string Description
{
get { return strDescription; }
set { strDescription = value; }
}
public string Value
{
get { return strValue; }
set { strValue = value; }
}
#region getLanguage
/// <summary>
/// getLanguage
/// </summary>
/// <returns></returns>
public DataSet getLanguage()
{
dalLanguage objdalLanguage = new dalLanguage(); // ERROR HERE
DataSet dsgetLanguage = objdalLanguage.getLanguage();
return dsgetLanguage;
}
#endregion
}
}
dalLanguage.cs
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Data.SqlClient;
using System.Web;
using Microsoft.ApplicationBlocks.Data;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Proj2;
namespace Proj2.DAL.Main.Setting
{
public class dalLanguage
{
public dalLanguage()
{
//constructor code here
}
#region getLanguage
/// <summary>
/// getLanguage
/// </summary>
/// <returns></returns>
public DataSet getLanguage()
{
DataSet dsgetLanguage = new DataSet();
try
{
dsgetLanguage = SqlHelper.ExecuteDataset(Constants.ConnectionString, CommandType.StoredProcedure, "[Main].[sp_getLanguage]");
}
catch (Exception ex)
{
throw ex;
}
return dsgetLanguage;
}
#endregion
}
}
答案 0 :(得分:4)
命名空间不匹配
Proj2.BLL.Main.Setting
Proj2.DAL.Main.Setting
您需要指定完全限定名称或导入名称空间。仅导入Proj2是不够的
答案 1 :(得分:1)
我注意到的第一件事是你在bllLanguage.cs中缺少使用语句。添加
using Proj2.DAL.Main.Setting;
bllLanguage.cs中的
答案 2 :(得分:1)
首先从不写
catch (Exception ex)
{
throw ex;
}
Throw ex会覆盖堆栈跟踪!
如果要重新抛出异常,请写入throw。
问题是他们在同一个项目中,如果没有,他们会引用另一个项目吗?