Running Mono 3.2.0 with .NET MVC 4

后端 未结 2 2009
日久生厌
日久生厌 2020-12-17 03:09

I am trying to get Mono 3.0 setup to run MVC4 sites under .NET 4 and .NET 4.5. I\'ve been working through various errors, what can I do to get it up and running?

相关标签:
2条回答
  • 2020-12-17 03:19

    Success

    If you want to run MVC4 on Mono, you need to use some Microsoft dlls which are not provided by Mono at this time.

    A word of caution - Taking a cursory look at the Mono source, there appears to be methods and classes in the MC4 source that do not exist in the 3.2.0 build. There may be features that are broken. The site I am running is for all intents and purposes an MVC3 site built against the latest dlls.

    Microsoft DLLs to copy

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

    Once you copy over the dlls, if you're still having problems you may have to do some detective work if the above fix doesn't work. If you get an error message saying that Mono can't find the DLL, it's usually one of three reasons:

    Troubleshooting

    1. Is doesn't have the dll - You can try using the Microsoft version of the DLL

    2. It's looking for an older version of the DLL when the correct one is installed in the GAC or in your project folder - An assembly in your project is likely referencing that version somewhere. You can use a binding re-direct to force the specific version you have be used instead

    3. It stil can't find the dll - Add the assembly in the compilation/assemblies section of your web.config

    4. You're getting a 'can't find view searched...' message - if any of the views in that particular views folder have compile errors, then you'll receive this message.

    0 讨论(0)
  • 2020-12-17 03:27

    Everything you need is now available within the Mono framework or on NuGet. I've created downloadable template for MVC4 for .Net 4.0 and .Net 4.5 and some notes on resolving the issues:

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

    The steps from the blog post are:

    • git clone github.com/chrisfcarroll/AspNetTemplatesForMono/Mvc4CSharpRazorFx45Intranet NB This github repo includes all the required dlls in case you don’t have NuGet working, so it’s an oversized download.
    • Open the solution in Xamarin Studio. It almost works out-of-the-box. The one thing you have to do is choose one of these 2 steps to make it work:

    Either delete 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 get at the command line with mono --version);

    The Microsoft.Web.Infrastructure.dll is required on .Net on Windows, so deleting it is not the simpler approach if you want cross-platform deployability

    0 讨论(0)
提交回复
热议问题