Search code examples
c#linq.net-assembly3-tier

Compile ERROR: The type is defined in an assembly that is not referenced


I'm working on a 3-tier application. I added a Linq to SQL table (LEAVE) using the O/R Designer. I added the method below for retrieving data from the table (LEAVE) in a class (LeaveRecord) in the Business Layer.

public IQueryable<LEAVE> getLeaves()
{
    dbContext db = new dbContext;
    return db.LEAVEs;
}

On the UI layer, in the code behind for the webform, I tried to get the data like this:

bll.LeaveRecord leaveRecords = new bll.LeaveRecord();
var data = leaveRecords.getLeaves(); // the error message highlights this line (41) as the offender

When I run the program, I get a compilation error:

The type 'programname.dal.LEAVE' is defined in an assembly that is not referenced. You must add a reference to assembly 'programname.dal, version=1.0.0.0, Culture=neutral, PublicKeyToken=null' (Line 41).

How can I resolve this issue?


Solution

  • The most simple solution is add reference to dal from the UI project.