I am attempting to get started with the Mono framework and have run into numerous issues, the latest of which has me exasperated. I have looked all over for a solution and haven't been able to figure this out.
Environment
Ubuntu 12.04 (on Hyper-V virtual machine)
Visual Studio 2012 (fully updated)
ASP.NET MVC 4
.NET Framework 4
Mono 3.4.0 (pulled and compiled directly from git using make)
XSP Mono.WebServer2 0.2.0.0 (also from git)
My mono installation follows the instructions from this answer almost exactly. What happens is this:
cd /var/www/mvc
in a bash prompt and run xsp4
.System.InvalidOperationException
The view 'index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
Description: HTTP 500. Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
at System.Web.Mvc.ViewResult.FindView(System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17 () [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, System.Web.Mvc.ResultExecutingContext preContext, System.Func`1 continuation) [0x00000] in <filename unknown>:0
Version Information: 3.4.0 (master/830c517 Fri Feb 28 16:03:26 CST 2014); ASP.NET Version: 4.0.30319.17020
I've attempted various compilation combinations (targeting 4.5 instead 4.0, using MVC 3 instead of 4), removed WebPages.OAuth.dll, copy-localed various reference combinations, and exhaustive web searches...all to no avail. Is it something to do with my Mono version? XSP? Is there a definitive solution for this issue?
UPDATE
If I target .NET Framework 4.5 with an MVC 4 project, the error changes to this:
System.IO.FileNotFoundException
Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies.
Description: HTTP 500. Error processing request.
Details: Non-web exception. Exception origin (name of application or object): DotNetOpenAuth.Core.
Exception stack trace:
at DotNetOpenAuth.Logger.Create(System.String name) [0x00000] in <filename unknown>:0
at DotNetOpenAuth.Logger.CreateWithBanner(System.String name) [0x00000] in <filename unknown>:0
at DotNetOpenAuth.Logger..cctor() [0x00000] in <filename unknown>:0
I am not using log4net.
After days of research, I've learned several things, first and foremost being that Mono 3.x is not supported on Ubuntu 12.04.
So, MVC 4 is out of the question on that OS (and most other Linux OS's that I messed with). For future reference, I was finally able to get MVC 3 working on Ubuntu 12.04 doing the following:
(Optional) Install XRDP, which allows remote desktop connections to Ubuntu VM. I can't stand the default terminal server window for Hyper-V with *nix systems, as the keyboard/mouse mappings are goofy.
sudo apt-get install xrdp
(Optional) Use ifconfig
at the terminal to get the VMs IP address which you can use for remote desktop connections.
Install Apache2.
sudo apt-get install apache2
Install Apache2 threaded dev (required for XSP4, installed below).
sudo apt-get install apache2-threaded-dev
Install Mono-runtime package.
sudo apt-get install mono-runtime
Install Mono-complete package.
sudo apt-get install mono-complete
Install XSP4 (this is a very light-weight web server you can use for development).
sudo apt-get install mono-xsp4
Install ASP.NET examples package. Apparently XSP4 doesn't install everything it needs, but requires some set of ASP.NET components be installed separately in order to work.
sudo apt-get install asp.net-examples
After this, you can set up a folder for your MVC 3 site in /var/www
and bin deploy your site. It is very important that certain assemblies are copied into your site folder to make it work, namely:
So make sure these are set to "copy local" or figure out where the right versions are on your Windows system and manually copy them to your site folder. Then, you can configure Apache and test your site using XSP4 (again, I'll give details if requested):
cd /var/www/sitefolder/
xsp4
Which will show you something like this:
xsp4
Listening on address: 0.0.0.0
Root directory: /var/www/sitefolder
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
And you can hit the site in a browser on the VM with localhost:8080
.
Hope this helps someone in the future.