新しいプロジェクト (C# の Web プロジェクト) を作成しました。プロジェクトに App_Code という新しいフォルダーを作成しました。次に、次のクラスを追加しました。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Shipper.DataLayer;
namespace Shipper.BusinessLayer
{
public static class BL
{
public static int JustSomeTest()
{
return 1;
}
}
}
そしてdefault.aspx
、コードビハインドの私のページの1つで、私はやろうとしました:
int i = BL.JustSomeTest();
と入力してもインテリセンスが得られませんBL.
。アセンブリまたは参照がありませんと表示されます。またはそれは言うでしょうThe name BL does not exist in the current context
。しかし、クラス ファイルが同じプロジェクトにある場合、参照を含める必要がありますか? プロジェクトをビルドしようとしたところ、最初はソリューション ファイルの名前で dll ファイルが生成されましたShipper.dll
が、この参照を追加するとすぐに、The name BL does not exist in the current context
.
default.aspx ページで、using ステートメントを追加しようとしました
using Shipper.
しかし、そうするとすぐに、名前空間 BusinessLayer が表示されなくなります...混乱していますか?
編集
以下は default.aspx です。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Shipper.BusinessLayer;
namespace Shipper
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SetDefaults();
int i = BL.JustSomeTest();
}
}
}
}
これが私のBL.cs
ファイルです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Shipper.DataLayer;
namespace Shipper.BusinessLayer
{
public static class BL
{
public static int JustSomeTest()
{
return 1;
}
}
}
The type or namespace name
エラーはBusinessLayerを読み取りますdoes not exist in the namespace Shipper (are you missing an assembly reference)?