Feasibility of C# development with Mono - c#

Recently, I came across Mono and MonoDevelop packages in Ubuntu linux. They claim to have a .NET runtime in accordance with CLI. Before installing the packages myself, I would like to know the following:
How powerful is Mono?
Can I develop GUI application for
linux like developing WinForm
applications for Windows.
Is MonoDevelop IDE compatible with Visual Studio IDE. Can I import VS 2008 solutions to MonoDevelop and work?
Does it support .NET 2.0 and above?
EDIT: Adding one more doubt
Is there any way to run the .NET exe (of a winform app) in Linux without building the cod e in linux? In fact I don't have the code for some of the small utilities I developed earlier and would like to run them in linux.

(Strange, markdown starts the enumeration with one, even though I began with 2...)
Yes, you can, but you're limited with 3rd-party components, because the internal implementation is different, and last time I checked (not very long ago), the Mono WinForms implementation made my test app look rather strange (owner-drawn list view). It is not really recommended, though Mono claims that it's now completely WinForms-2.0-compatible.
MonoDevelop is/was a SharpDevelop branch, with the latter having solution support. I don't know if MonoDevelop has. But the cool thing is, you can just develop with Visual Studio and run your compiled apps on Mono. And Mono is, by the way, also available for Windows.
Yes, it does, as far as the CLR goes. As Marc Gravell already wrote, the Windows Foundation libraries are missing, as are a few other (System.Management, for example). But things should mostly work, including ASP.NET 2.0. Mono's application portability guidelines are a good read on this.

1: pretty good, actually. Not all the full framework is there, so if you are writing code that should build on both MS .NET and mono, you need to build and test early against both platforms
4: yes - although things like WPF/WCF/WF (3.0) are missing or slimmed down
I don't know much about the development environment, since I use VSTS (on Windows) and just use a NANT script to do the build on mono...

Define "powerful".
Mono has a WinForms implementation to allow for some level of source compatibility. However, depending on your needs, you might want to use one of the Mono bindings for a Linux native framework, like Gtk# or Qyoto
Wouldn't know.
Depends on what parts of .NET you mean. C# the language seems to be pretty current, things get fuzzier the closer you get to the enterprisey features as was already mentioned.
To sum things up, if you'll be using Mono as a separate target platform, you're likely to have good results. If you want a no-code-changes-required .NET compatibility layer, less so.

Very powerful. There are no major bugs in the core implementation. It is not a science project. The deficiencies are mostly where you would expect, the newest APIs (Microsoft inherently has a first-mover advantage there).
Yes. We just finished a project where most of the GUI code was developed in WinForms on Windows. I was able to work on it using Ubuntu without major headaches. That said, this is one of the hardest parts of the API, and there are still issues. See http://mono-project.com/WinForms for details.
Don't know, as I don't use it.
Yes, though again, there may be some missing APIs in the runtime.
Note, I use Ubuntu Hardy (8.04).

Mono is mighty powerful. It has all the .Net muscle on a very strong open source skeleton.
When you say "develop GUI application for linux like developing WinForm applications for Windows" I understand that you are asking about a visual designer that will allow you to quickly create the UI. Yes, it is possible. MonoDevelop has Stetic - a built-in visual designer for Gtk#. There is also QyotoDevelop which enables QT support in MonoDevelop.
Yes, MonoDevelop natively supports VS project/solution file format. You can use the same code base to compile your app with VS in .Net on Windows and win MD in Mono on Linux.
Currently Mono supports C# 3.0 with some stuff beyond that already implemented and a lot in the pipeline.
Yes, in many cases it is possible to run a .Net compiled app in Mono, however with MonoDevelop's support for VS solutions it doesn't really matter. It takes as much as pressing F7 to rebuild the whole project, so the effort is really negligible. The best tool for checking if your application can run in Mono is MoMA.

Mono is very powerfull, sometimes even more powerfull than Microsoft's implementation. link text
Yes you can. Winforms 2.0 is supported
I believe so.
Yes it does. C# 3 is supported and just look at winforms and the asp.net implementation to see how much is supported from each of the projects. Look at http://mono-project.com

I use WinForms in mono. The 2.x releases are very good.
I develop forms in visual-studio on windows, and run them in Linux, with zero code changes. Yes, forms look a little different than on XP, but then again, an XP-themed GUI would look kind of strange in GNOME.
If you are just getting started, stick with WinForms, while you get comfortable with Mono/Linux. However at some point you might want to investigate GTK.

Related

Library compatibility between C# .NET vs C# Mono

I wanted to tryout C# for general purpose programming (not web development). I program in Windows environment, but I would like to avoid coding specifically for Windows (.NET), because I want to keep the option open for a future migration to Linux.
Are there any specific libraries in C# .NET that wouldn't work in C# Mono for general purpose programming work (not interested in Windows Forms, Silverlight and stuff like that) ?
Is there any internet link of things/features that provides a list that works on C# .NET wouldn't work on C# Mono or vice versa? I didn't readily find anything in google per se.
Note: I would be interested in specific answers, not opinions of which is better or worse (thanks!)
It is possible for a CLR assembly (even in the form of a DLL, as mentioned in the comments) to be read by Mono, as long as it does not have dependencies that do not exist in Mono, because...
...not every piece of code that compiles for .NET will compile for Mono, since there are lots of Windows-specific things in .NET (not strictly part of C#) that aren't implemented (WPF, ASP.NET async stack) or don't make sense at all in Linux (COM is one such example, I think).
Fortunately, there is a list of what .NET features are implemented in Mono. Even more fortunately, it seems they have an app that tells you a priori whether your code makes use of anything not implemented in Mono (but I have never tried it).
if you install xamarin (you need Pro or bigger so you have VS integration) you can create Portable Class Library that targets xamarin (which is based on mono) and visual studio will allow you to only use classes that are compatible with mono.
http://docs.xamarin.com/guides/cross-platform/application_fundamentals/pcl/introduction_to_portable_class_libraries/
apparently you can also use xamarin studio to create a PCL and there is a free version of that.

Using async-await on .net 4

I'm currently starting to create an application that would profit a lot from C# 5's async-await feature. But I'm not sure which version of VS and of the async runtime to use.
Looking at OS popularity charts, I'll need to support Windows XP for another three years or so. It looks like .net 4.5 runs only on newer versions of Windows, so I need to target .net 4.0. The development machines use Windows 7, so using a newer version of VS is not a problem.
Now I need to first choose a compiler for doing this:
VS2010 with AsyncCTP
VS2012 Preview (and final once it arrives), setting the target to .net 4.0
Mono (Looks like 2.12 has async-await, I prefer/am used to VS over MonoDevelop as IDE)
Which one has fewer code-gen bugs? Looking at Jon Skeet's blog the VS2012 Preview uses a never code-generator than the CTP.
And more importantly which runtime to use?
Does VS2012 contain a redistributable async runtime for use with .net 4?
I managed to compile code, with the preview, by referencing the AsyncCTP runtime. But since the CTP has strange licensing conditions, that doesn't look like a good long term solution.
Or should I use a third party implementation? Perhaps mono has one?
For distributing the library I prefer simply putting the dll in the same directory as the application, instead of some kind of installer.
I'd also like it if my binaries would work without changes on mono+Linux/MacOS. So the runtime should either be compatible with whatever mono (2.12 probably) has built in, or allow use on non windows OSs.
Microsoft released the Async Targeting Pack (Microsoft.Bcl.Async) through Nuget as a replacement for the AsyncCTP.
You can read more about it here: http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx.
You can read about the previous version here: http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx.
As this pack is officially supported, I now believe the best option for targeting XP + async would be using Visual Studio 2012 + C#5 + Async Targeting Pack.
If you feel the need to target .NET 3.5 though, you can still use (my) AsyncBridge for .NET 3.5.
If you are open to considering other .Net languages, F# can solve your problem. It has had the async{} computation expression for years, and is backwards compatible even with .Net 2.0. Minimum requirement is Windows XP SP3. The runtime can be downloaded here.
It's possible to use the VS 12 beta to target .NET 4.0 using async/await.
You need to copy some code into your project that provides the types that the compiler relies on.
Details here
Edit: we've taken this technique and turned it into a open source library called AsyncBridge:
https://nuget.org/packages/AsyncBridge
If you want to be able to distribute your software, I think that the Mono solution is really your only option right now. You also say that you want the end result to run on Mono over Linux and OS X. Targeting Mono to begin with seems like the natural solution.
Your next issue is the IDE. MonoDevelop would obviously work well but you say you prefer Visual Studio.
Greg Hurlman created a profile to code against Mono 2.8 from Visual Studio. If you follow-up with him, he might be able to point you in the right direction for developing against Mono 2.11/2.12 in Visual Studio.
Of course, there is also Mono Tools for Visual Studio which is a commercial product. I assume that it is still being offered by Xamarin.
You might also be able to run the required 4.5 profile assemblies from Mono on top of .NET but I have not tried that. The 4.5 profile is a strict super-set of the 4.0 API. Perhaps give it a shot and report back.
EDIT: It looks like perhaps you can use the Visual Studio Async CTP in production now
Here is what it says on the download page:
Includes a new EULA for production use. Note - This license does not
constitute encouragement for you to use the CTP for your production
code. The CTP remains an unsupported and use-at-your-own-risk
Technology Preview. However, we’ve received many requests from
developers to use the CTP for production code, and so have changed the
license to allow that.
If you want to start distributing your software after MS releases C# 5.0, then you can start developing using AsycnCTP.
Otherwise I wouldn't recommend you to use it, as it is just CTP, not even a beta. It can be changed a lot close to the beta stage and to the release. It may be unstable, etc.
If you want to introduce easy async operations in your application I would recommend you to use Reactive Extensions and stuff built on top (Reactive UI, etc), it is just beautiul.
As for VS2012, it also contains the same Async CTP as far as I remember from my //Build/ tablet MS gave me on that conference.

C# .NET 2.0 components

How can I check what objects, tools, variables, anything... are used from .NET 2.0 in a C# application.
How can I get a C# application run without .NET 2.0 ?
UPDATE:
sorry, I didn't clarify enought. Here's my situation: I have developed a pretty simple application in C#: embeded browser which displayes static webpages with an option of searching inside of these html pages. I'm using simple textbox, buttons components for this.
The application will be distribuited for people wich have very old PCs, even with windows 95. I would like the app to be runable on it, or at least on win 98, without telling the people to install .NET 2.0, as the users don;t really have PC usage skills :) .
I'm using a dataGridView as well.
You can have a look at this : http://www.remotesoft.com/linker/
"The mini-deployment tool puts
together the minimum set of CLR
runtime files and dependent assemblies
that can be simply copied to a single
folder on a target machine, and your
application runs as if the whole
framework is installed. Since the
installation is isolated into a single
folder, there will be no conflicts
with future .NET installation. When
linking is used for the dependent
assemblies, it will further reduce the
file size."
You may need to clarify a bit more.. do you want the app to run without .Net at all? Or you want it to run in .Net 3.5 without .net 2.0 bits?
If its the latter, then simply don't reference assemblies that are compiled in .net 2.0 (check the properties on the reference you have added). If its the former, then its really not feasable. Yes its possible, but it means deploying parts of the framework with your app, but then, you'd be deploying all the bits, including the 2.0 bits.
Your're question really needs more information though, it doesn't make much sense currently. Sorry. =)
To make sure it runs without .NET 2.0, compile it with the .NET 1.1 compiler.
But this seems like not a good idea. I'd recommend revisiting your requirements.
Win98 wasn't shipped with .NET. Using .NET v1.1 won't get you much more platform penetration than .NET 2.0, if any.
IT looks like windows 98 supports the .net framework. See this answer for details:
OS Compatibility for various .NET Framework versions
You cannot run a .NET application (i.e., that uses the CLR) if you haven't installed the corresponding .NET Framework binaries (i.e., that contains the CLR) directly or indirectly.
Period.

Is C# platform neutral?

Today I purchased C# 3.0 Pocket Reference (O'Reilly Publishers).
In that book in the first para of the first page it is given that "The C# language is
platform neutral, but it was written to work well with Microsoft .Net platform"
If I am not wrong, Platform Neutral mean that the softwares made from that language should run in all the OS(e.g.Mac, Windows,Linux etc.).
I know that this characteristic is being satisfied by Java but .Net has not yet been able to do that(Though MONO has made some progress in Linux).
Then what is the significance of that word "PLATFORM NEUTRAL" so far c# is concern?
Thanks in advance
The C#-language itself is platform neutral like C and C++ are - you can implement a compiler et al for it on any platform.
The .Net platform and its associated libraries however, which it was designed to work well with, are not platform neutral in design - they are designed to work on windows, although Mono does compensate somewhat for that.
If you would write a C# program without using any features of any .Net-library it is guaranteed to be platform-independent - you can be sure it will run on any platform that has tools for C#... you just won't have a particularly useful program though ;)
C#, the language, is platform neutral.
But the frameworks usually associated with C#, the dotNEt environment, are not. They run on Microsoft's OS-es.
Mono enables C# on many other (mostly unix-oid) platforms by providing the necessary runtime environment, but it doesn't come with (all) the frameworks needed to run typical C# programs.
Don't forget you can use C# in:
MS .NET (Windows)
.NET Compact Framework (PocketPC, XBox 360)
Silverlight (Windows, Mac)
Moonlight (Mono / Linux)
MonoTouch (iPhone)
MonoDevelop (various including android)
Micro Framework (some watches etc)
Not exactly bad coverage. The language has very few requirements on the runtime / OS.
C# is platform neutral in the sense of OS (i.e., OS neutral) if you count Mono as a reliable runtime on Linux.
But, C# and .Net can run as it is, without recompilation, on both 32 and 64 bit machine. I guess this is the meaning of the author.
In this case, platform neutral is defined as "being able to run on any machine that has a compatible virtual machine". Depending on what language features and compiler you use, C# could be considered able to run on machines running recent versions of Windows, Mac OS and Linux.
C# the language can be implemented on any platform which has a compatible compiler and virtual machine. The language itself has an ECMA standard for implementation, and thus does not itself contain any platform (i.e. Microsoft) specific language elements.
Before answering the question, one must consider that any language these days is useless without its libraries. That said many namespaces that make up part of are windows only. Many are just wrappers around microsoft technologies, like com, win forms, etc.
All things considered just take a look at the adjustments mono has made to provide alternatives to dot net. Miguel has mentioned many times that they hope Silverlight will win rather than other ui toolkits because it is truely platform independent rather than wpf and winforms etc.
If you want a true multi platform language and environment look at Java.
In my view, Microsoft's claim that C# is platform neutral (repeated by the text you are quoting from) is disingenuous.
It is technically correct, but in practice the limited portability of C# applications to non-MS operating systems has happened despite Microsoft rather than because of them. It is pretty clear that Microsoft has no intention of supporting C# / .Net on any non-MS operating system. Indeed, many people think that Microsoft (via its patent licensing deal with Novell) is using C# / Mono as a "wedge" to damage the GNU / Linux ecosystem.
IMO, anyone thinking of using Mono needs to consider: 1) the risks to their project if MS decides to play hardball about .NET patents, and 2) the damage they might be doing to the open-source ecosystem as a result.

Can c# compiled app run on machine where .net is not installed?

I want to develop a small utility for windows and I prefer doing that in c# because it is easier (I'm a java developer).
The utility will be available for download by many people and I assume some of them will not have the .net framework installed (is this assumption correct, say I target win xp and above?)
My question is: can a c# application be compiled in a way that it will not require the .net framework installed?
Normally, you will need the .NET Framework being installed on the target system. There is no simple way around that.
However, certain third-party tools such as Xenocode or Salamander allow you to create stand-alone applications. See this related question:
Is there some way to compile a .NET application to native code?
As these solutions are not straight-forward and require commercial products I would recommend you to create a simple Visual Studio Setup and Deployment project. In the properties of the project you should include the .NET Framework as a pre-requisite. The setup.exe created will then automatically download and install the .NET Framework prior to installing your application.
No, it will need the .Net framework installed. Note though that you will need only the redistributable version, not the SDK.
A minor aside - but in this scenario, consider developing the utility in Silverlight - it has a much smaller footprint and is supported on a number of operating systems. This might allow you to get the coverage including people who don't already have .NET.
If you need "normal" .NET, then "Client Profile" is perhaps an option.
You can probably also include the .net framework installer in your application.
In a related question, Can you compile C# without using the .Net framework?, it's mentioned you could do this using mkbundle from mono. I haven't tried it myself so I can't comment on if it's the way you should go, but you may want to consider it.

Categories

Resources