[Mono-list] Running ASP.Net 4.5 MVC Application on Mono

Fernando Rodriguez frodriguez.developer at outlook.com
Tue Sep 16 22:11:32 UTC 2014


On Tuesday 16 September 2014 10:13:55 PM Martin Thwaites wrote:
> That last error is misleading.  I think someone did look into fixing the
> error message.  It basically masks the underlying error.  Check your logs,
> you'll probably see the actual error.

ATM I'm running it on xsp4 directly so I *think* any error would be displayed 
on the terminal but  I'll look into it. At the moment my gut tells me it's the 
third part of the error message that applies: "or no view engine supports the 
searched location". Maybe because it's an MVC5 file which apparently the 
current release of Mono's System.Web.Mvc.dll doesn't support? Right now I'm 
building the latest mono from git as I read somewhere that the 
AppendTrailingSlash issue is fixed and it should run Microsoft's MVC5 
assemblies.

Another hint that that may be the case is that I don't have the ViewBag 
property on my controller class. I think earlier version used ViewState or 
something like that. So after I fixed that my app is in effect an MVC3 
application (except for the cshtml files).
 
> In terms of the packages ending up in bin... From your description you
> appear to missing how references work.  Deleting the nuget packages doesn't
> stop things from being copied in.  It's how you define the reference in the
> csproj file (by defining "copy local" as true).  Apologies if you knew
> that, but your description wasn't clear.
> 
> Also, you shouldn't really be referencing the assemblies with a full path,
> you should do it through the GAC.

I understand how they work, and I did had the copy local checked at that time, 
but the point is that I'm referencing Mono's assembly and it's copying 
Microsoft's. I think it's because MonoDevelop bundles Microsoft's assemblies  
(either that or Microsoft's code built against a later version of Mono than 
the current release). I did not look deep into this yet but it is obvious by 
the fact that they reference the AppendTrailingSlash.

I also know that I should use the full path. The reason I did it is because 
MonoDevelop doesn't list all GAC assemblies, apparently it's package oriented 
and it's got a package called Mono but it doesn't include them all.

> There was a PR for the append trailing slash one, not sure where it ended
> up though.
> 
> What I would say though is, what are you using that requires MVC 4? Could
> you revert to MVC3? As that does work on mono.

Really I don't NEED anything from that requires MCV 5. The only features that 
my app uses at the  moment is the view file format (I already fixed the ViewBag 
issue). Really I'm just trying to catch up with MS technologies. I'm MS 
certified developer but I haven't worked with it for several years (since 
around the time .NET 3.0 came out) and I never looked into MVC before so I 
decided to port an existing WebForms website (which runs on Linux) to the 
latest MVC.

I will end up reverting to MVC 3 anyways since I don't want to run an unstable 
mono on a live server but I do want a linux environment to play with MVC5 
features and that's what this is about.

Thanks for the reply. I will post the outcome if it works with the latest 
mono. Let me know if you have any other ideas.

> On 16 Sep 2014 20:07, "Fernando Rodriguez" 
<frodriguez.developer at outlook.com>
> wrote:
> 
> > Thanks for the replies.
> >
> > I did made some progress, that specific error is my xsp was quite old, I
> > built
> > it from the latest tarball on Mono's website but it is outdated, so I had
> > to
> > get it from github.
> >
> > After that I got another missing method exception:
> > System.Web.Routing.RouteCollection.get_AppendTrailingSlash. This method
> > does
> > not exist currently in mono (I read it's on the current github tree but
> > not on
> > releases). So obviously it's because my app was using MS assemblies.
> >
> > So I installed Mono and MonoDevelop 5.1 from tarballs on a desktop. Then
> > opened the solution removed all Package References and added References to
> > the
> > right assemblies on /usr/local/lib/mono/4.5 and deleted everything in the
> > bin
> > directory. It still wouldn't compile because it doesn't find the ViewBag
> > property on the Controller class (I guess because it's a dynamic type and 
I
> > guess Mono can't handle it), so I created quick custom ViewBag extension
> > and
> > it compiled but I still get the same error so I look on the bin directory
> > and
> > they're back! I don't know where MonoDevelop got them cause I deleted them
> > from packages directory. So I deleted everything from the bin directory
> > except
> > for my DLL and a couple third party DLLs (everything else is in the GAC),
> > then
> > without recompiling I ran from my project directory root.
> >
> > xsp4 --root . --applications /:.
> >
> > now I'm getting:
> >
> > 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/Default/Index.aspx
> > ~/Views/Default/Index.ascx
> > ~/Views/Shared/Index.aspx
> > ~/Views/Shared/Index.ascx
> > ~/Views/Default/Index.cshtml
> > ~/Views/Default/Index.vbhtml
> > ~/Views/Shared/Index.cshtml
> > ~/Views/Shared/Index.vbhtml
> >
> >
> > But Views/Default/Index.cshtml is there with rwx permission for everyone.
> > As a
> > desperate move I even tried copying the View directory to my home
> > directory in
> > case it was interpreting ~ to be my home dir instead of the app root. So
> > right
> > now I'm stuck. I'm using the right case on the url. Any suggestions?
> >
> >
> >
> >
> >
> > On Tuesday 16 September 2014 3:32:31 PM Martin Thwaites wrote:
> > > Have you made sure to remove the Microsoft.Web.Infrastructure.dll file...
> > >
> > > There is a tutorial somewhere about running MVC 3 on mono (which I do
> > with
> > > great success).  There a few files that you need to make sure are not
> > > deployed as part of your application.
> > >
> > > That said, I've not tried anything 4.5 related on mono yet.
> > >
> > > Also, you could try compiling from git, it maybe more upto date that the
> > > tarball.
> > >
> > > Hope that helps
> > > Martin
> > > On 16 Sep 2014 05:41, "Fernando Rodriguez"
> > <frodriguez.developer at outlook.com>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I'm trying to get an Asp.Net 4.5 MVC app to run on mono and I'm 
getting
> > the
> > > > error shown bellow (also posted here). I get the same error in apache
> > using
> > > > mod_mono as in xsp4. I built mono, xsp, and mod_mono on the server 
from
> > the
> > > > latest tarball releases (simple ./configure && make && make install).
> > Other
> > > > Asp.Net applications run fine on the same server (targetting earlier
> > > > runtimes).
> > > > The server run Gentoo and I remove all mono, xsp, and mod_mono 
packages
> > > > before
> > > > building the source.
> > > >
> > > > I found several posts that suggest a bug in xsp (don't apply since I'm
> > > > using
> > > > latest tarball and also tried earlier versions) or mono loading the
> > wrong
> > > > framework version stack trace and exception message suggest is loading
> > the
> > > > right assemblies (most assemblies on the 4.5 directory are symlinks to
> > > > 4.0). I
> > > > did tried to run xsp.exe with mono ---runtime=v4.5 and it tells me 
it's
> > not
> > > > available, same for 4.0 but it is available and the and the exception
> > shows
> > > > it's using it.
> > > >
> > > > The application was built on Windows with Visual Studio but I also
> > built
> > on
> > > > MonoDevelop (Xamarin) on Windows to target Mono. It does not use any
> > > > external
> > > > references except for PayPal's API Library but I used this same
> > library on
> > > > other applications that run on mono so that shouldn't be the problem.
> > I'm
> > > > trying to setup a parallel mono environment on a Linux desktop to
> > compile
> > > > it
> > > > on Linux to see if it makes a difference (my distro's version are
> > really
> > > > outdated).
> > > >
> > > >
> > > > Another thing I noticed is that Visual Studio copies all the Mvc and
> > Razor,
> > > > etc assemblies to the bin folder, if I delete them mono wines about 
not
> > > > finding
> > > > them even though there's Mono's implementation on the GAC (which I
> > believe
> > > > are
> > > > built from the same source). Also in the Visual Studio generated
> > > > Web.config the
> > > > <httpRuntime> and other tags had a targetFramework="4.5" attribute,
> > and I
> > > > had
> > > > to remove it cause mono wined about it (unrecognized attribute or
> > something
> > > > like that). Yet the same Web.config works fine in Mono under Windows.
> > > >
> > > > I think that's all I got, suggestions are appreciated.
> > > >
> > > > Exception caught during reading the configuration file:
> > > > System.MissingMethodException: Method not found:
> > > > 'System.Configuration.IConfigurationSectionHandler.Create'.
> > > >   at
> > > >
> > > >
> >
> > 
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
> > > > (System.String configKey) [0x00000] in <filename unknown>:0
> > > >   at System.Configuration.ConfigurationManager.GetSection
> > (System.String
> > > > sectionName) [0x00000] in <filename unknown>:0
> > > >   at System.Configuration.ConfigurationManager.get_AppSettings ()
> > > > [0x00000] in
> > > > <filename unknown>:0
> > > >   at Mono.WebServer.XSP.Server.get_AppSettings () [0x00000] in
> > <filename
> > > > unknown>:0
> > > >   at Mono.WebServer.XSP.Server+ApplicationSettings..ctor () [0x00000]
> > in
> > > > <filename unknown>:0
> > > > xsp4
> > > > Listening on address: 0.0.0.0
> > > > Root directory: /var/www/stage.fernansoft.net
> > > > Listening on port: 8080 (non-secure)
> > > > Hit Return to stop the server.
> > > > Missing method
> > > >
> > > >
> >
> > 
System.Configuration.IConfigurationSectionHandler::Create(object,object,XmlNode)
> > > > in assembly /usr/local/lib64/mono/4.0/System.dll, referenced in
> > assembly
> > > > /usr/local/lib64/mono/4.0/System.Configuration.dll
> > > > Missing method
> > > > System.Configuration.ConfigurationManager::get_AppSettings() in
> > > > assembly
> > > >
> > > >
> >
> > 
/usr/local/lib64/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll,
> > > > referenced in assembly
> > > >
> > > >
> >
> > 
/usr/local/lib64/mono/gac/Mono.WebServer2/0.4.0.0__0738eb9f132ed756/Mono.WebServer2.dll
> > > > Missing method
> > > > System.Configuration.ConfigurationManager::get_AppSettings() in
> > > > assembly
> > > >
> > > >
> >
> > 
/usr/local/lib64/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll,
> > > > referenced in assembly /usr/local/lib64/mono/4.0/System.Web.dll
> > > > Missing method
> > > > System.Configuration.ConfigurationManager::get_AppSettings() in
> > > > assembly
> > > >
> > > >
> >
> > 
/usr/local/lib64/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll,
> > > > referenced in assembly /usr/local/lib64/mono/4.0/System.Web.dll
> > > > Missing method
> > > >
> > > >
> >
> > 
System.Configuration.ConfigurationProperty::.ctor(string,Type,object,TypeConverter,ConfigurationValidatorBase,ConfigurationPropertyOptions)
> > > > in assembly
> > > >
> > > >
> >
> > 
/usr/local/lib64/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll,
> > > > referenced in assembly /usr/local/lib64/mono/4.0/System.Web.dll
> > > >
> > > >
> > > > ---------
> > > > Fernando Rodriguez
> > > > frodriguez.developer at outlook.com
> > > > _______________________________________________
> > > > Mono-list maillist  -  Mono-list at lists.ximian.com
> > > > http://lists.ximian.com/mailman/listinfo/mono-list
> > > >
> >
> > --
> > ----------
> > Fernando Rodriguez
> > frodriguez.developer at outlook.com
> > _______________________________________________
> > Mono-list maillist  -  Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >

-- 
----------
Fernando Rodriguez
frodriguez.developer at outlook.com


More information about the Mono-list mailing list