Question

I have created a folder in my website in asp.net C# usindg VS'10 ,,

Now i added a class into that folder with namespace as under:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ThreeTierSample.BLL
{
  /// <summary>
  /// Summary description for Student
  /// </summary>
public class Student
{
    public Student()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public void insert()
    { 

    }
  }

}

I want to use this namespace into code behind file for that i'm trying to include namespace with statement :

using ThreeTierSample.BLL

but the problem is that it will not allow me to add this namespace even it doent show in intellisence.

Help me to resolve this issue.

Below is the screen shot of my project hierarchy:

enter image description here

Was it helpful?

Solution

Considering that your student class is in different project of the same solution and you want to use that class in some other project let's say web project where you have all of your UIs.

So we have to projects in one solution.

  1. Student.BLL
  2. Student.Web

To solve your problem you must have to add your Student.BLL project as an reference into your Student.Web project.

Below are the steps to add the project as an reference. :

  1. Right click on the Student.Web project
  2. Select Add -> Reference
  3. One popup window will be displayed
  4. In right panel of that popup, select solution
  5. In middle panel your list of projects will be displayed. Select Student.BLL from there and click OK as mentioned below :

enter image description here

Now you can access your class with the namespace.

Note : I have observed in your snapshot that you have wrote ThreeTierSamle.BLL instead of ThreeTierSample.BLL (You have forgotten 'p' in 'Sample')

OTHER TIPS

try this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ThreeTierSample.BLL;

namespace ThreeTierSample.BLL
{
public class Student
{
    public Student()
    {
    } 
    public void insert()
    {     
    }
  }
}

public class TestingClass
{
Student myStudent = new Student();  //  THIS IS OUTSIDE THE ThreeTierNamespace
                                    //  and will work                                      

}

you may have the threetier namespace nested in another that's why it's not showing up in our intellisence

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top