43

Goal: Startup a ASP.NET MVC 5 project on Mono via Xamarain Studio.

Error after starting server: Could not load file or assembly 'System.Web.Entity' or one of its dependencies.

enter image description here

Error in Xamarin Studio:

enter image description here

Background: The project was created in Visual Studio 2013 as a default web project. Most of the configuration is out of the box. Code for it can be viewed here on GitHub. I have the latest and greatest Mono and Xamarin Studio as of writing. The .NET Entity Framework is a resolved dependency and there are no build issues noted in Xamarin Studio.

How do I get this project up and running? How do I resolve this dependency?

jeffmaher
  • 1,824
  • 3
  • 21
  • 20

4 Answers4

22

I know this is an old thread, but I ran across this while starting to port over an MVC project from VS for windows to VS for Mac. I found a better solution was to delete the reference to System.Web.Entity, and add the NuGet package System.Web.Http.Common. Hope it helps.

  • 3
    I got an error when I added NuGet package System.Web.Http.Common. So I ended up removing the reference to System.Web.Entity without adding anything to replace it. – JSWilson Jan 21 '19 at 17:36
7

I was able to work around this problem by getting the System.Web.Entity.dll file from my Windows box. I found mine in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\.

Once I copied that to the bin folder of my project on my Mac, and updated the reference to include a HintPath...

<Reference Include="System.Web.Entity" >
  <HintPath>..\bin\System.Web.Entity.dll</HintPath>
</Reference>

the project would build in Xamarin Studio. It still showed the red X next to the reference (yes, even if I specified that it was a local copy and added a HintPath), but at least it could find it.

I ended up getting another error about being unable to load System.Drawing.BitmapSuffixInSameAssemblyAttribute, but hey, small progress!

Matteo Guarnerio
  • 720
  • 2
  • 9
  • 26
jonnybot
  • 2,435
  • 1
  • 32
  • 56
  • isn't this assembly supposed to come in a nuget package or something? – knocte Jan 13 '16 at 03:37
  • I would think so, but evidently not? Xamarin studio's Nuget restore didn't get it, though I've never had trouble building the project that requires it in Visual Studio, quite possibly because the dll comes with the .NET Framework that's installed on Windows. – jonnybot Jan 13 '16 at 15:29
  • 1
    Create a project in Visual Studio using the ASP.NET MVC template. After the project is created, go to the References folder, right-click on the "System.Web.Entity", choose Properties. In Properties, check CopyLocal as True. Go to the bin folder of the project, the DLL will be there; Now just copy it to Linux and do what is described in the answer above – Paulo Amf Apr 25 '17 at 02:57
1

Wouldn't it be better/easier for you just to replace that old EntityFramework with new one from NuGet, I think that will solve most of our problems with other references

MrTommek
  • 103
  • 9
-1

Is EntityFramework.dll copied to your bin? In visual studio you can do the below enter image description here

Arun
  • 42
  • 1
  • 8