views:

550

answers:

2

I have one solution with three projects.

  1. DomainModel (C# Library with ADO.NET Entity Framework)
  2. DomainModelTest (Unit Testing for Business Logic)
  3. WebApp (Using DomainModel)

For some reason, I cannot even bring the view if I pass any of the objects in the DomainModel, not even simple. I get the error below:

Any ideas?

Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

Line 146: Line 147:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] Line 148: public class views_home_index_aspx : System.Web.Mvc.ViewPage, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler { Line 149:
Line 150: private static bool @__initialized;

I thought this might be helpful, the actual error comes up on the Default.aspx file in the line pointed below:

public partial class _Default : Page
{
    public void Page_Load(object sender, System.EventArgs e)
    {
        // Change the current path so that the Routing handler can correctly interpret
        // the request, then restore the original path so that the OutputCache module
        // can correctly process the response (if caching is enabled).

        string originalPath = Request.Path;
        HttpContext.Current.RewritePath(Request.ApplicationPath, false);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current); //**HERE**
        HttpContext.Current.RewritePath(originalPath, false);
    }
}
+4  A: 

Try adding the reference in your web.config, in the < assemblies > section.

AJ
Thanks!!!! I spent around 1.5 hour on this alone. Is this a known bug? Thanks anyway.
Geo
I don't think I would call it a bug... Including the reference in the project is the first step. If you want to use it in a controller you have to have a 'using' statement, if you want to use it in a view it needs to be in the web.config or imported declaritively in the view markup. I banged my head against it too a few times, but I've learned my lesson now :)
AJ
@AJ, I'm pretty much of the opinion that this is a bug. Normally when I add a reference to a web app, I only have to add it once.
ProfK
i wouldn't say bug - i'd say poor error message for an undestandable bit of miscoding. "BUT IT IS F*ING REFERENCED!!"
BritishDeveloper
+3  A: 

In web.config Add this

`

    <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

`

Saiful