ASP.NET MVC 1 and 2 on Mono 2.4 with Fluent NHiber

2019-02-01 06:23发布

问题:

I'd like to create an application using ASP.NET MVC, that should run under mono 2.4 (compiling will be done on a Windows box). Has anyone getting luck with this? Here is what I've already tried:

  1. ASP.NET MVC on mono without any persistence model support, and using nhaml as the view engine
  2. S#aml architecture, which is a quite good framework imho, but it depends too much on stuff, that are not working good under mono (like windsor)

The first part worked fine, I didn't encounter any major problems. But I couldn't get the second part working. It seems it's dependency on Castle.Windsor breaks the whole mono support (but there might be other parts too).

Therefore I decided to create an alternative framework, that borrows some of the ideas of s#arp-architecture, but designed to be working under mono (and if I'm able to do this I'll release it for the community of course). The controller and view part is working fine (not much magic here though, they have been always working), but I have some questions before I start job on the persistence part:

  • What NHibernate versions are working under mono? I've heard 1.2 is working fine. Does 2.0.1/2.1 beta work under mono?
  • Does Fluent.NHibernate and NHibernate.Linq work under mono? (for the latter it seems it needs some dependcies that aren't avaialable in mono)
  • Are there any good alternatives for persistence support to NHibernate under mono?

Alternative questions:

  • Are there any frameworks that have mono+persistence+asp.net mvc support already or am I the first one to think about this?
  • If you have already done this: what are your opinions on stability/usability?

Thanks for the answers

EDIT: Updated the framework to support ASP.NET MVC 2: http://shaml.sztupy.hu/

回答1:

I am using mono 2.4 to run a asp.net mvc app + windows service. Compatibility is very good. There are some bugs and differences than with windows but once you learn what they are it gets easier (there can be pain at the start!)

I am using NHibernate (2.1) FluentNhibernate, StructureMap, NBehave, Moq and open id lib and they all just seem to work as expected.

As for stability, since I have ironed out the major bugs in my code I haven't had any problems.

Usability, well it is a completely different platform so you need to come to it with an open mind and be prepared to leave behind the windows way.. the good news is that once you do that things get easier. Apache is a lot nicer than IIS and configuring and managing a linux box is just easier than windows.

I am pretty glad I choose mono.. sorry this is starting to sound like a PR drive - but I am just really happy with it!!



回答2:

Okay. I started on a new project that incorporates the best from S#arp Architecture with stuff, that work on mono. Instead of T4Toolkit it uses a ruby script to do the generation job, just as with rails or merb.

To use install the shaml gem from github:

gem install shaml

Then create a new application:

shaml generate app AppName

And create resources:

shaml generate resource NewRes "name:string;date:DateTime"

S#aml Architecture project homepage: http://shaml.sztupy.hu/

GitHub project: http://github.com/sztupy/shaml/tree/master