Running Mono 3.2.0 with .NET MVC 4

I am trying to run Mono 3.0 to run MVC4 sites under .NET 4 and .NET 4.5. I worked with various errors, what can I do to start and run?

Server configuration

  • CentOS 5
  • Apache 2.2.3
  • 3.2.0 (tarball Sun Jul 28 00:57:40 UTC 2013); ASP.NET Version: 4.0.30319.17020 2013)
  • The latest XSP from git since this post

Apache / Mono Configuration

MonoServerPath "/usr/local/bin/mod-mono-server4" 
Content

/ usr / local / bin / mod-mono-server4:

 #!/bin/sh exec /usr/local/bin/mono $MONO_OPTIONS "/usr/local/lib/mono/4.5/mod-mono-server4.exe" " $@ " 

Update

The essence of the problem is that Mono does not come with MVC4, which is required by the site. He still has the MVC3 DLL, but he has the Razor 2 dll, but not the Razor 1 dll that MVC3 wants to sue.

+4
source share
2 answers

Success

If you want to run MVC4 in Mono, you need to use some Microsoft DLLs that are not currently provided by Mono.

A word of caution. A quick look at the Mono source in the MC4 source has methods and classes that are not in assembly 3.2.0. There may be malfunctioning functions. The site that I launch is, for all purposes and purposes, an MVC3 site created against the latest dlls.

Microsoft Libraries for Copy

  • System.Web.Abstractions - 4.0
  • System.Web.Helpers - 2.0
  • System.Web.Mvc - 4.0

As soon as you copy the DLL files, if you are still having problems, you may have to do some detective work if the fix does not work. If you get an error message stating that Mono cannot find the DLL, this is usually one of three reasons:

Troubleshooting

  • I don't have a dll - you can try using the Microsoft DLL version

  • It searches for an older version of the DLL when the correct one is installed in the GAC or in your project folder. Perhaps the assembly in your project is referencing this version somewhere. You can use re-direct bindings to force the specific version you used.

  • This cannot find the dll - add the assembly to the compilation / assembly section of your web.config

  • You get the message "cannot find the search ..." - if there are compilation errors in any of the views in this particular folder, you will receive this message.

+1
source

Everything you need is now available as part of Mono or NuGet. I created a downloadable template for MVC4 for .Net 4.0 and .Net 4.5 and some troubleshooting notes:

http://www.cafe-encounter.net/p1510/asp-net-mvc4-net-framework-version-4-5-c-razor-template-for-mono-on-mac-and-linux

Steps from the blog post:

  • git clone github.com/chrisfcarroll/AspNetTemplatesForMono/Mvc4CSharpRazorFx45Intranet NB This github repo includes all the necessary DLLs in case you do not have NuGet, so it is oversized.
  • Open the solution in Xamarin Studio. It almost works out of the box. The only thing you need to do is select one of these two steps to make it work:

Or remove Microsoft.Web.Infrastructure.dll from the bin \ directory and from the project

Or from the command line:

 sudo mkdir /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry sudo chmod g+rwx /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry 

(replacing 3.2.5 with your mono version, which you will get on the command line with mono -version);

Microsoft.Web.Infrastructure.dll is required on .Net on Windows, so uninstalling is not simpler if you want to use cross-platform deployability

+5
source

Source: https://habr.com/ru/post/1493830/


All Articles