天道酬勤,学无止境

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

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/

评论

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!!

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

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • NInject, nHibernate, and auditing in ASP.NET MVC
    I am working on an inherited application which makes use of NInject and nHibernate as part of an ASP.NET MVC (C#) application. Currently, I'm looking at a problem with the auditing of modifications. Each entity has ChangedOn/ChangedBy and CreatedOn/CreatedBy fields, which are mapped to database columns. However, these either get filled with the wrong username or no username at all. I think this is because it has been configured in the wrong way, but I don't know enough about nHibernate and NInject to solve the issue, so I hope someone can help. Below some code snippets to hopefully provide
  • How do I make an XML file an embedded resource in a vNext (ASP.NET 5) class library?
    I have an MVC 6 (vNext/ASP.NET 5) project, with one class library for the DAL(Data Access Layer). Now I am getting an exception because NHibernate can't find the mapping file for an entity I am trying to persist. I have seen strict instructions to mark this XML mapping file as an embedded resource and not to copy to output, but in none of the three property pages I manage to open for this file, is there anywhere to stipulate this. I am simply going to move to code-based fluent mapping, but this issue isn't unique to my one NHibernate mapping file. The old property page for project items
  • 流利的接口-方法链接(Fluent Interfaces - Method Chaining)
    问题 方法链接是我知道的建立流畅接口的唯一方法。 这是C#中的示例: John john = new JohnBuilder() .AddSmartCode("c#") .WithfluentInterface("Please") .ButHow("Dunno"); Assert.IsNotNull(john); [Test] public void Should_Assign_Due_Date_With_7DayTermsVia_Invoice_Builder() { DateTime now = DateTime.Now; IInvoice invoice = new InvoiceBuilder() .IssuedOn(now) .WithInvoiceNumber(40) .WithPaymentTerms(PaymentTerms.SevenDays) .Generate(); Assert.IsTrue(invoice.DateDue == now.AddDays(7)); } 那么其他人如何创建流畅的界面。 您如何创建它? 需要什么语言/平台/技术? 回答1 您可以使用任何版本的.NET或任何其他面向对象的语言来创建流畅的界面。 您需要做的就是创建一个对象,该对象的方法始终返回该对象本身。 例如在C#中: public class JohnBuilder {
  • Castle Windsor IoC in an MVC application
    Prepare for a wall of code... It's a long read, but it's as verbose as I can get. In response to Still lost on Repositories and Decoupling, ASP.NET MVC I think I am starting to get closer to understanding this all. I'm trying to get used to using this. Here is what I have so far. Project Project.Web (ASP.NET MVC 3.0 RC) Uses Project.Models Uses Project.Persistence Project Project.Models (Domain Objects) Membership.Member Membership.IMembershipProvider Project Project.Persistence (Fluent nHibernate) Uses Project.Models Uses Castle.Core Uses Castle.Windsor Membership.MembershipProvider
  • .NET Core与Mono(.NET Core vs Mono)
    问题 .NET Core和Mono有什么区别? 我在官方网站上发现一条声明:“为此编写的代码也可以跨应用程序堆栈(例如Mono)移植”。 我的目标是使用C#,LINQ,EF7和Visual Studio创建一个可以在Linux上运行/托管的网站。 有人告诉我他想让它成为“单声道”,但我不知道那是什么意思。 我知道我想将.NET Core 1.0与上面列出的技术一起使用。 他还说他想使用“快速CGI”。 我也不知道那是什么意思。 如果我的期望是现实的,您能帮助我理解所有这些术语吗? 回答1 死灵法师。 提供实际答案。 .Net Core和Mono有什么区别? .NET Core现在正式是.NET的未来。 它在很大程度上是从重新编写ASP.NET MVC框架和控制台应用程序开始的,其中当然包括服务器应用程序。 (由于它是图灵完备的,并且支持与C dll的互操作,因此,如果您绝对愿意,也可以使用它编写自己的桌面应用程序,例如通过诸如Avalonia之类的第三方库,这在当时是非常基础的我首先写了这篇文章,这意味着您几乎只限于Web或服务器。)随着时间的流逝,.NET Core中已经添加了许多API,以至于在3.1版之后,.NET Core会跳到5.0版。不带“核心”的.NET 5.0,这将是.NET Framework的未来。 过去,完整的.NET Framework将在维护模式下像完整的
  • 在ASP.NET MVC 5 Mono中使用Razor Url帮助器时找不到方法“ RouteCollection.get_AppendTrailingSlash”(Method 'RouteCollection.get_AppendTrailingSlash' not found when using Razor Url helpers in ASP.NET MVC 5 Mono)
    问题 我正在Mono(Ubuntu 14.4,Monodevelop 5.9,Mono JIT编译器版本4.0.1)中创建ASP.NET MVC 5应用程序。 我看到某些剃刀组件无法识别,例如: @Url.Action 当我添加这个 <a title="Notifications" href="@Url.Action("_Listing","Home")"> Home </a> 我收到此错误: System.MissingMethodException 找不到方法“ RouteCollection.get_AppendTrailingSlash”。 从包中引用了System.Web.Mvc 。 还有其他要求吗? 更新:到目前为止,我尝试了以下解决方案: Razor View Engine是否适用于Mono? 是否可以在mono下使用Razor 2.0视图引擎? http://www.davidloo.com/?p=479 http://iws.io/walkthrough-porting-asp-net-mvc-website-to-mono-2-6-1-and-mysql-on-linux-apache-porting-to-mono-part-3-之3 / 看来这是一个已知问题,但我坚信应该有一些破解方法才能起作用。 我也尝试使用aspx引擎,但没有收获。 回答1 最新的消息是
  • 与.NET 2.0 / 3.5一起使用的最佳免费ORM工具(Best free ORM tools to use with .NET 2.0/3.5 [closed])
    问题 从目前的情况来看,这个问题不适合我们的问答形式。 我们希望答案得到事实,参考或专业知识的支持,但是这个问题可能会引起辩论,争论,民意测验或进一步的讨论。 如果您认为此问题可以解决并且可以重新提出,请访问帮助中心以获取指导。 9年前关闭。 我对即将进行的项目使用对象关系映射包感兴趣。 该项目将从ASP.NET应用程序开始,但将具有最终将与WinForms应用程序共享的许多功能。 谁能提出一些在ASP.NET和WinForms情况下都能很好地工作的免费ORM软件包吗? 回答1 SubSonic不如nHibernate广泛。 相反,它是每个表数据访问层的直接Active Record 1类。 其中一些功能是查询工具,执行存储过程的功能以及ASP.net中的脚手架应用程序。 您可以在30分钟或更短的时间内启动并运行,并且学习曲线很小,并且Config.app文件中的配置最少。 回答2 我总是推荐城堡ActiveRecord。 它是NHibernate之上的一层。 在您提到的两种环境中,它都可以很好地工作。 回答3 nHibernate为我工作,但这完全取决于您所追求的。 很多人不想遵循完整的DDD和单元测试路线。 他们只需要一些简单的方法就可以将数据库映射到对象,以使代码更好。 如果是这样的话,那就看看Subsonic吧,它可能更容易上手。 回答4 我更喜欢Fluent
  • NHibernate session management in ASP.NET MVC
    I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog post: http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/ Using this class, my repository looks like this: public class UserRepository : IUserRepository { private readonly ISessionBuilder _sessionBuilder; public UserRepository(ISessionBuilder sessionBuilder) { _sessionBuilder = sessionBuilder; } public User GetByID(string userID) { using (ISession session = _sessionBuilder.GetSession()) { return session.Get<User>(userID); } } } Is this the best way to
  • 循环引用导致Automapper堆栈溢出(Circular reference causing stack overflow with Automapper)
    问题 我正在使用Automapper将NHibernate代理对象(DTO)映射到CSLA业务对象 我正在使用Fluent NHibernate创建映射-运行正常 我的问题是, Order有集合OrderLines每一个都有一个参考Order 。 public class OrderMapping : ClassMap<OrderDTO> { public OrderMapping() { // Standard properties Id(x => x.OrderId); Map(x => x.OrderDate); Map(x => x.Address); HasMany<OrderLineDTO>(x => x.OrderLines).KeyColumn("OrderId").Inverse(); Table("`Order`"); } } public class OrderDTO { // Standard properties public virtual int OrderId { get; set; } public virtual DateTime OrderDate { get; set; } public virtual string Address { get; set; } // Child collection properties public
  • Method 'RouteCollection.get_AppendTrailingSlash' not found when using Razor Url helpers in ASP.NET MVC 5 Mono
    I am creating an ASP.NET MVC 5 application in Mono (Ubuntu 14.4, Monodevelop 5.9, Mono JIT compiler version 4.0.1). I see that some of the razor components are not recognized, eg: @Url.Action When I add this <a title="Notifications" href="@Url.Action("_Listing","Home")"> Home </a> I get this error: System.MissingMethodException Method 'RouteCollection.get_AppendTrailingSlash' not found. System.Web.Mvc is referenced from the packages. Is there anything else which is required? Update: I tried these solutions so far: Does the Razor View Engine work for Mono? Is it possible to use Razor 2.0 view
  • Where can I find a good NHibernate and ASP.NET MVC Reference Application
    Where can I find a good NHibernate and ASP.NET MVC Reference Application? I downloaded S#arp and this seemed to be a lot more than I needed (IOC and CodeGen via T4). I might work my way up to this later, but I need something smaller at first. Any simple examples? I just want to pick up how NHibernate Session handling works in ASP.NET MVC. And maybe how some simple query scenarios work. Still trying to grasp how a SELECT DISTINCT would be done in NHibernate and through to the View via the ViewData.
  • ASP.NET MVC (Domain Model, Repository, Fluent, Services - Structure for my Project)
    In my ASP.NET MVC web application, I have: Domain Model, created by LINQ to SQL Repositories such as UserRepository and OrderRepository IQueryable Fluents as IQueryable Extension Methods such as public IQueryable<Order> GetNewOrders(this IQueryable<Order>) Services such as UserService and OrderService Utility Classes and Extension Methods such as CryptoUtility (doing Hashing etc.) and String etc. extensions ViewModels which are special for each MVC View The ASP.NET MVC project itself (Controllers, Views) I'm looking for the best project structure/organization for my case, especially separating
  • Where to find C# sample code to implement password recovery in ASP .NET MVC2
    How to implement password reset in MVC2 application? Passwords are hashed using ASP .NET membership provider. Password recovery question is not used. Standard ASP .NET MVC2 project template with standard AccountController class is used. If user forgots password, email with temporary link or with new password should sent to user e-mail address . Where to find code to implement this in MVC 2 C# ? stack overflow contains two answers which discuss methods about implementing this. There is not sample code. I googled for "asp .net mvc password reset c# sample code download" but havent found sample
  • How can you create Clustered Indexes with Fluent NHibernate?
    I am using Fluent-NHibernate (with automapping) to generate my tables but would like to choose a different clustered index than the ID field which is used by default. How can you create clustered indexes with Fluent NHibernate on a field other than the default Primary Key field? The primary reasoning behind this is simple. I am using Guids for my primary key fields. By default, NHibernate creates clustered indexes on the primary key fields. Since Guids are usually not sequential, clustering on the primary key field causes a performance issue. As we all know, appending records at the end of a
  • 什么时候应该在ASP.NET MVC中使用异步控制器?(When should I use Async Controllers in ASP.NET MVC?)
    问题 我在ASP.NET MVC中使用异步操作时有些担心。 什么时候可以改善我的应用程序的性能,什么时候不可以? 在ASP.NET MVC的任何地方使用异步操作是否很好? 关于等待方法:当我要查询数据库时(通过EF / NHibernate /其他ORM),我应该使用async / await关键字吗? 一个单一的操作方法可以使用await关键字异步查询数据库多少次? 回答1 当一个动作必须执行几个独立的长时间运行的操作时,异步动作方法很有用。 AsyncController类的典型用法是长时间运行的Web服务调用。 我的数据库调用应该是异步的吗? IIS线程池通常可以比数据库服务器处理更多的同时阻止请求。 如果数据库是瓶颈,异步调用将不会加快数据库响应速度。 如果没有限制机制,则通过使用异步调用有效地将更多工作分配给不堪重负的数据库服务器,只会将更多的负担转移到数据库上。 如果您的数据库是瓶颈,那么异步调用将不是魔术。 您应该看一下1和2参考 源自@PanagiotisKanavos评论: 而且,异步并不意味着并行。 异步执行使宝贵的线程池线程免于阻塞外部资源,而没有任何复杂性或性能成本。 这意味着同一台IIS机器可以处理更多的并发请求,而不是运行得更快。 您还应该考虑到阻塞调用始于占用大量CPU的Spinwait。 在压力时期,阻止呼叫将导致延迟升级和应用程序池回收。
  • Github上优秀的.NET Core开源项目的集合
    内容包括:库、工具、框架、模板引擎、身份认证、数据库、ORM框架、图片处理、文本处理、机器学习、日志、代码分析、教程等。 Github地址:https://github.com/GeekPowerFelixSun,[awesome-dotnet-core] 其中的翻译有可能有问题,大家发现了及时提出来,其他的比较好的项目也可以提出来,我会及时添加修改上去的。 一般 ASP.NET Core Documentation - 官方ASP.NET核心文档站点。.NET Core Documentation - .NET Core,C#,F#和Visual Basic技术文档的主页,包括基本概念,入门说明,教程和示例。.NET Core SDK - .NET Core SDK是由Microsoft和.NET社区在GitHub上维护的通用开发平台。.NET Platform Standard - 旧版本和新版本的.NET之间存在差异。Introducing .NET Standard 2.0 - 介绍.NET Standard 2.0的内容和当前.NET标准中某些缺失部分的路线图。.NET/.NET Core代码整洁 - 适用于.NET / .NET Core的代码整洁。.NET Framework源码 框架, 库和工具 API autorest - Swagger(OpenAPI
  • 如何使用流利的NHibernate将枚举映射为int值?(How do you map an enum as an int value with fluent NHibernate?)
    问题 问题确实如此,默认是将其映射为string但我需要将其映射为int 。 我目前正在使用PersistenceModel来设置我的约定,如果有什么不同的话。 提前致谢。 更新发现从主干上获取最新版本的代码解决了我的麻烦。 回答1 定义此约定的方式有时是在以前更改的,现在是: public class EnumConvention : IUserTypeConvention { public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria) { criteria.Expect(x => x.Property.PropertyType.IsEnum); } public void Apply(IPropertyInstance target) { target.CustomType(target.Property.PropertyType); } } 回答2 因此,如上所述,从后备箱中获取最新版本的Fluent NHibernate将我带到了我需要的地方。 具有最新代码的枚举的映射示例为: Map(quote => quote.Status).CustomTypeIs(typeof(QuoteStatus)); 自定义类型强制将其作为枚举的实例进行处理,而不是使用GenericEnumMapper<TEnum
  • C# (mono) Linux web server hosting with consistent static variables across threads
    Does anybody know of a C# (mono) Linux web server hosting configuration that enables consistent static variables across threads (ie not the CGI model of an instance per thread)? Details I have some c# (mono) code that we need to host on linux as part of a simple web app. We don't need any traditional asp or even asp.net mvc features, really we just need the ability to respond to specific urls with dynamic content based on shared static variables. Static Variables: The one special requirement we do have is that we need static variables to retain their value across all incoming requests (the
  • Mapping enum with fluent nhibernate
    I am following the http://wiki.fluentnhibernate.org/Getting_started tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with fields Id AccountTypeName Right now the account types can be Savings or Current So the table AccountTypes stores 2 rows 1 - Savings 2 - Current For AccoutType table I have defined enum public enum AccountType { Savings=1, Current=2 } For Account table I define the entity class public class Account { public virtual int Id {get; private set;} public virtual string
  • Programming to interfaces while mapping with Fluent NHibernate
    I have been whipped into submission and have started learning Fluent NHibernate (no previous NHibernate experience). In my project, I am programming to interfaces to reduce coupling etc. That means pretty much "everything" refers to the interface instead of the concrete type (IMessage instead of Message). The thought behind this is to help make it more testable by being able to mock dependencies. However, (Fluent) NHibernate doesn't love it when I try to map to interfaces instead of concrete classes. The issue is simple - according to the Fluent Wiki, it is smart to define the ID field of my