ASP.Net web forms compilation says Entity Framework reference missing - asp.net

I have a website using ASP.Net Webforms and Entity Framework and during compilation VS2010 tells me the following error:
error 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'.
The problem is that the reference is properly configured in web.config
The properties page of the project says that the Framework version used in the project is v3.5, which is correct.
Any help will be appreciated.
This is the assemblies section in my web.config
<assemblies>
<add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>.

can you show your web.config references? My guess is that either the version # is off, or that perhaps the EF assmebly is not installed in the GAC.
Check that the exact version you want is referenced in web.config
If the assembly is in your bin directory, right click on it in Windows Explorer and choose 'Properties' and find the version. Make sure it matches web.config.
If you are relying on the GAC, open c:\windows\assembly in Windows Explorer to see if that exact version of the EF assembly is there

The only time I get that is when the DLL is missing from a project, and it may not just be the root project. If you have another project that uses the EntityObject class, and its missing there, you'll get the error.

Related

wrong module specified in web.config

Visual Studio 2010
I have System.Web.MVC 2 and System.Web.Routing 4 referenced in my project.
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
I am getting a following error when specifying a module:
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing, Version=4.0.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Error: Wrong module specified. System.Web, version 4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Note: i am upgrading Kentico CMS to new version and they are now utilizing routing also. The upgrade document wants to add a module with version 3.5.0.0. Since i have version 4.0 referenced, i cant do 3.5.
Try
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Compilation error in .NET 4.0 web.config - Linq not found

I can compile and test my .NET 4.0 web application just fine within Visual Studio 2010. If, however I point my local IIS to the folder containing the application, I get the following error:
Compiler Error Message: CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
Source Error:
Line 388: <add namespace="System.ComponentModel.DataAnnotations" />
Line 389: <add namespace="System.Configuration" />
Line 390: <add namespace="System.Linq" />
Line 391: <add namespace="System.Text" />
Line 392: <add namespace="System.Text.RegularExpressions" />
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config Line: 390
How is it that the web.config from the framework won't compile for me?
I have found similar problems on the web and most just say 'add this reference...', but it can't be the right thing to edit the default web.config -- can it?
This worked for me. Have this assemblies in the web.config file
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
I think you need to add the assemblies below in your web.config -
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
You will get System.Linq in core assembly
If you have a website, asp.net needs proper references to be able to compile it. A web application would not need that.
There are some assemblies referenced in the machine.config, some might be missing depending on your code, you can add them to machine.config or the root web.config.

Error while running the code after migrating

I have an application in asp.net2.0 with C#. I have migrated my application in .NET 3.5 & I am receiving the below error.
Could not load file or assembly 'Microsoft.Build.Framework' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Please let me know how I can solve this.
Thanks in advance.
in the web.config
in the assemblies place the right versions - or remove Microsoft.Build.Framework
<compilation ... >
<assemblies>
...
</assemblies>
Here is my assemblies for 3.5 project.
<assemblies>
<add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>
You can also create a new empty project and see what he makes on your web.config and by compare the new to the old, fix the old one by just keeping your values.

Removing all assemblies from <compilation><assemblies> in ASP.NET 4 web.config [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What is the purpose of the Assemblies node in Web.Config?
I removed all the 'add' elements in the compilation/assemblies element.
So initially in my application's root web.config file:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
Now it looks like:
<compilation debug="true" targetFramework="4.0">
<assemblies>
</assemblies>
</compilation>
And my application still works. The project file still has all the references I removed, but this section appears to be unused during compilation (inside visual studio).
What is going on?
The references in this section of the application are used for the automatic ASP.NET compilation that is done on the fly. If you are deploying a compiled site, (no .cs or .vb files) then you are fine to remove it.

ASP.NET MVC 2 - Views in separate assembly - No intellisense

I've searched over the topics on Stackoverflow but this question hasn't been answered so far.
I have two projects in my solution: a) MVC Application b) Class Library.
The class library acts as a plugin, so it contains views. The main problem is that I have no intellisense in the view's markup for my classes contained within the class library (the same assembly as the views).
In the beginning I couldn't even write <%= Html.RenderAction... %>. I've solved that by adding a Web.config file to the class library with the following section:
<configuration>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
Now it recognizes Html.RenderAction, etc in the view's markup. However I've no idea how to get access (with intellisense) to my classes contained within the same assembly as the views :(
Kind regards,
Jakub
There is a separate list of namespaces in the config where you need to include your custom namespaces. The example below demonstrates in the simplified web.config you add your namespaces. If this still does not work make sure that your project and webconfig has correct references to the other assembly.
<configuration>
<pages>
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
<add namespace="Blog.Models"/> <!-- These are my custom namepaces -->
<add namespace="Blog.Views"/>
</namespaces>
</pages>
</configuration>
The Spark viewengine as the same issue, see their documentation. Basically they say 'make a web app project' and treat it like a class library in every other way. Worked for me in Spark, maybe it'll work in your situation as well?
Out of the box, MVC does not support multiple projects. Check my previous questions for more detail.

Resources