13
votes

Alrighty guys, I'm writing an application that I want to be cross-platform. Up until recently I've been trying to do this in Silverlight with C# because it also runs on OS X, but with me being fairly rusty with C# in addition to being new to Silverlight I've run into headache after headache. Most of this stems from the restrictions that come along with an application that's intended to run in a browser, issues with it running differently when running from my development sever vs directly from a file://, etc.

I'd rather completely abandon the whole OS X support idea than have to completely rewrite the app for OS X, especially since I have utterly NO experience writing for it. What I'm hoping to be able to do is write a regular app in C# .NET with Visual Studio for Windows and then easily port it to OS X with Mono.

How difficult is it to bring a .NET app over to OS X with Mono? My app is fairly straightforward, there's nothing exotic going on with the forms or anything, so I'd have to assume that it'd be supported in Mono's WinForms implementation.

Are there any good resources out there on how to port an app using Mono? Or, perhaps, am I missing the entire point and it simply lets you run .NET apps on OS X and I don't need to bother with porting?

Forgive my utter ignorance on the subject, I only started considering going this route like 10 minutes ago after running into yet another annoying restriction in Silverlight.

I'll be the first to admit that I don't know my head from my ass about this subject, so be gentle.. :)

4
This might help: mono-project.com/MoMANick
If you want to write a program with a proper Cocoa interface, you could also look into MonoMac mono-project.com/MonoMacLuke
MoMA is out of date now, but there's a Visual Studio extension called .NET Portability Analyzer that will analyze your assembly for portability to a number of platforms, including Mono.Malcolm

4 Answers

5
votes

Appart from MoMa as mentioned in the other answers you might be interested in MonoMac. With the success of MonoTouch (writing c# for iPhone), there is now also a project called MonoMac to create native UI's for OSX while using .net/mono in the background. Might be interesting for you http://www.mono-project.com/MonoMac, article on Miguel de Icaza's blog: http://tirania.org/blog/archive/2010/Apr-19.html

2
votes

In addition to what has been said already, considering that Mono supports a subset of the full .NET functionality, I would probably prefer to develop on Mono, then test against Microsoft's runtime, if the aim is to run on both of those. Otherwise, you run the risk of inadvertantly using some functionality that isn't available in Mono, and have to throw a large chunk of code out the window by the time you get around to doing the cross-platform build and testing.

1
votes

Mono project has a page dedicated to how to port applications,

http://mono-project.com/Guidelines:Application_Portability

However, it is never enough as your application can be unique in so many ways.

Try to port it and report issues to Mono guys whenever necessary. Besides, if you work for a firm, consider Mono's commercial support service,

http://mono-project.com/Support

1
votes

There are several things you should keep in mind.

  1. you'll have to port any usage of platform depedendent UI code
  2. don't use platform dependentent OS calls (win32 api)
  3. don't use "exotic" libraries (like workflow, sadly ef)
  4. In general: abstract dependencies to such code away, so you can easily replace them with mono-specific libraries. (an adviseable pattern would be MVVM).

There is a tool called MoMA that will help you with all that. However, take the results with a grain of salt. In any case, just try it.