The Limitation of Mono Runtime

2019-05-01 17:37发布

问题:

My question is similar to this one and this one, but there is a slight difference. So that's why I am asking it here.

I have a shiny .Net 3.5 Windows Service ( with NHibernate, LINQ, lambda expression) etc, running on Windows. Now I plan to port my app to Linux, so I am thinking about Mono.

Can I just compile my .net app in Windows, and copy it to a Linux machine with .Net ( mono version) installed, and expect it to run smoothly? If not, is there anything I should do?

Any answers or pointers are welcome.

回答1:

Start by using the MoMA tool

The Mono Migration Analyzer (MoMA) tool helps you identify issues you may have when porting your .Net application to Mono. It helps pinpoint platform specific calls (P/Invoke) and areas that are not yet supported by the Mono project. While MoMA can help show potential issues, there are many complex factors that cannot be covered by a simple tool. MoMA may fail to point out areas that will cause problems, and may point out areas which will not actually be an issue

From Personal point: All C# 3.0 feature are supported well, I had no problem with LINQ (To Objects, don't know about LINQ to SQL or to XML) and NHiberinate also works well (although I didn't end up using in)



回答2:

Will it just work? You really have to test it. I've just recently put effort into making Protocol Buffers work on Mono. I've had very little execution-time trouble so far; the compiler was more of an issue for me. However, I've had to temporarily disable one of the unit tests (using mocking) because it makes the Mono 2.4 VM itself go bang. I haven't investigated why yet, but that sort of thing is basically impossible to predict.

Anything which uses "deep" aspects of the CLR - such as expression trees and dynamic methods - is likely to have more problems than simple libraries, IMO.

Now, you say it's a Windows service - obviously Linux doesn't have services in quite the same way as Windows, so you'll need to work out how you want it to run. I'd start off by running it as a simple console app if I were you... once it's all working, you can think about integrating it with other "service" controllers etc - if you find you need to.

It certainly used to be the case that xbuild didn't provide a seamless migration path from building on Windows to building on Linux... however, it's had a lot of attention recently, so it's worth trying again...



回答3:

The runtime should be fine but you can run the Mono Migration Analyzer.



标签: .net mono