how to port .NET application to mono - c#

Since I was not satisfied with my C# application not working on Linux or Mac, I installed MonoDevelop in hopes of porting my application to Mono for cross-platformability.
However, I don't know how how to use MonoDevelop to accomplish this task. There's no instructions in FAQ or Documentation.
Any idea how to do it?

From MonoDevelop FAQ:
Can I import my Visual Studio 2K5+ project into MonoDevelop?
MonoDevelop can open, manipulate and save MSBuild-based projects
directly in most cases. In fact, since MonoDevelop 2.0 the default
project format has been VS2008-style MSBuild projects, but VS2005 and
VS2010 formats are also handled.
Google is still your friend:
How to port your .Net applications to Linux using Mono tools for Visual Studio
Using Mono to port a C# .NET app to OS X?

Related

Visual Studio mac 2019 (Community) - PresentationCore - Assembly not found for .Net Framework 4

I'm working on an existing solution at work that was written in C# targeting .NET Framework 4 in Visual Studio 2019 for Windows. I'm attempting to open the project on my MacBook Pro (running Catalina 10.15.6 if that's relevant) in Visual Studio Mac 2019 Community (Version 8.7.7 Build 10) so I can keep working on this remotely.
I'm noticing that a usage of System.Windows.Media isn't being found. My understanding is that this relies on PresentationCore, which I believe is included in .NET Framework 4. Sure enough, in the project's References, PresentationCore has a red "x" next, with alt text telling me "Assembly not found for framework .NET Framework 4".
Is there any way to add this? Is this just something not supported in macOS? I'm happy to provide any additional information.
You are trying to run a WPF application, which targets .Net Framework (4), on MacOS.
MacOS doesn't support WPF, or any version of .Net Framework, as .Net Framework is Windows-dependent1.
Image source: https://visualstudio.microsoft.com/vs/mac/
.Net Core is supported - that's the cross-platform version of .Net, which works on Windows, Mac, and Linux.
You'll need to do a migration to make it work with Core. Of course, this still won't allow you use to run WPF on a Mac, you'd need to use another cross-platform supported UI framework.
1 Of course, Mono is the open-source version of .Net Framework that runs on Mac and Linux, so you can also try that as an option if you're feeling adventurous or can't migrate to Core.
See also: Can you install and run apps built on the .NET framework on a Mac?
Gunr2171 is correct; but you could also look at running a virtual box on your Mac for a windows environment then use VS Code.
For a VM I recommend
https://www.virtualbox.org/wiki/Mac%20OS%20X%20build%20instructions
Then Windows 10 OS:
https://www.microsoft.com/en-ca/software-download/windows10ISO
Just an idea if Mono doesn't work for you.

Compile VS2010 c# solution (project) on ubuntu

What's the best way to build a c# solution made with Visual Studio on Ubuntu? Is there a way to convert the .sln file to a makefile? Should I use Mono?
The first thing I would do would be to use Moma to check to see if your program will run under Mono as is. You can also use MonoDevelop which can use Visual Studio Projects.
From their faq: In fact, since MonoDevelop 2.0 the default project format has been VS2008-style MSBuild projects, but VS2005 and VS2010 formats are also handled.
C# is a .NET language, .NET is a Windows-based framework. It has been ported to Linux operating systems (Ubuntu included) via the Mono Project. So yes, you need to use Mono.
Mono is the best I've tried. It says on their homepage that they are binary compatible between each other, so if it's already built, you could just run it on Mono. No need to recompile.
Your best bet is to use Mono if you want to use a process like MsBuild. Mono has xBuild that is similar. This SO question has some information about using Mono.

Using a Mono Reference assembler (tweetsharp)

I developed an app that uses Tweetsharp, now I would like to convert that app with mono but I am kinda new to this world!
I downloaded mono, monodevelop and moma and I noticed that in Tweetsharp there is a solution for mono.
I tried to build it with either visual studio and monodevelop but both give me errors. So what is the right procedure to generate a reference for mono applications?
And the reference has to be used with monodevelop or I can use it also in VS using a directive?
From its GitHub history we can see there are few commits to the Mono folder now (Feb 1 2012),
https://github.com/danielcrenna/tweetsharp/commits/master/src/mono
Therefore, I think this library is not yet Mono compatible. If you are not capable of helping port it to Mono, you would have to wait till its authors finish the port, or find another library in this field who supports Mono.

How to port a Mono GTK# app to other platforms?

I am working on a Mono GTK# desktop app written in C#. I have developed my app using the MonoDevelop IDE (v2.4.2) on a Mac (OS X v10.6.7). My app depends on the GTK# library (obviously) as well as the Mono.WebServer2 library for running a local ASP.NET server.
I have tested my app on my own Mac as well as other Macs. Everything is working out great. Now, I am interested in porting my app to other platforms (specifically, Windows 7 and Ubuntu v11.04). I have been playing around with the mkbundle command but I haven't had any luck in creating a working bundle for other platforms than Mac OS X.
Since I have tried a number of different solutions without success, I would like to hear from the Mono developers out there. What do you do to port your app to other platforms?
I have been developing C# using Visual Studio for a long time but I am new to the Mono development environment. Therefore, I would very much appreciate a detailed explanation.
Thank you very much!
It doesn't really sound like you're talking about porting, rather packaging. MonoDevelop's "Project/Create Package" function can create simple binary packages (zips etc) or source packages (source plus makefiles) but these are not the ideal form to distribute to most end-users. Some additional work is required to make a polished installer for each platform.
mkbundle bundles the Mono runtime into your app, therefore it creates binaries that are 100% platform-specific.
For Mac, the usual way to distribute an app is as an app bundle. MonoDevelop doesn't automate this for GTK# projects, but I explained how to do it on my blog.
For Ubuntu, you can distribute a zip of binaries and require that your users install Mono, GTK# and xsp. If you create a .deb package, you can embed these dependencies into the package manifest. MonoDevelop doesn't have any tools for creating deb/rpm linux packages, and I'm not familiar with the process myself.
For Windows, you can provide a zip of binaries and require that your users install .NET and GTK# for .NET. You could also create a msi installer and have it check for these prerequisites.
It sounds like you have already solved the problem of packaging for Mac.
On Ubuntu, you would want to create a .deb package that contains your app and requires other packages as dependencies (Mono, Mono.WebServer2, GTK#, GTK+, etc). The following link should get you started on building Ubuntu packages:
https://wiki.ubuntu.com/UbuntuDevelopment
For Windows, you probably already know how to build an installer if you have .NET experience. I would say that you would want to run your app on top of .NET instead of Mono. That is what the Mono team do themselves (for MonoDevelop as an example). Bring in the Mono specific bits like Mono.WebServer2 as part of your application.
Your biggest issue here will be that GTK# requires the GTK+ C libraries to be installed. Probably the easiest thing is to detect if GTK# is installed as part of the installer and ask your users to install GTK# if they need it. You are going to have to do the same detection for the .NET version you require anyway. You can get GTK# for Windows here.
I do not have great instructions for doing this but both the Banshee and MonoDevelop projects do it well. I would take a look at those projects as they will show you exactly what needs to be done.
https://github.com/mono/monodevelop
http://git.gnome.org/browse/banshee
EDIT:
I just recently realized that the code for the GTK# installer is on GitHub here.
There are is also packaging projects available in Monodevelop. you can use them.
I'm doubtful that mkbundle work well other than Linux.
Another option that open your project on other plateform (you can use Monodevelop) and build the project and use some other app to build package.
I just recently created deb package of my own .Net project written in MonoDevelop. From MonoDevelop I created a package with sources and makefiles (makefiles also generated by MonoDevelop) and then i used this guide>
http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html
to create deb package. Dependencies were mono-runtime and gtk-sharp2.

MonoDevelop in windows

Is there a version of Monodevelop that runs on Windows? If so where can I get it?
MonoDevelop officially supports Windows since 2.2. You can check the what's new in Monodevelop 2.2 or download the last release.
Windows Support
Windows now Officially Supported
Windows is now an officially supported
platform for running MonoDevelop. Many
Windows specific issues have been
fixed, and some add-ins such as
debugging and subversion support have
been written specifically for Windows.
Windows Installer
We are releasing a new Windows
Installer which includes almost all
you need to run MonoDevelop. The only
external dependency is gtk#, which is
provided in a separate installer.
It looks like you can build it and run it on Windows, but I don't think there is a binary download available yet. From the docs, here:
Does MonoDevelop work on Windows?
Yes. MonoDevelop can be built and run
on Mono on Windows, although it is
still unstable and some features may
not be available. We are currently
working on a Windows installer that
will be soon be available.
There are no precompiled binaries, so you'd have to build from source. Even then, there seems to be some stability issues running MonoDevelop on Windows (see here).
Some alternatives would be SharpDevelop and/or Visual Studio Express.
Update: MonoDevelop version 2.2 and higher officially supports Windows. You can get the latest version here: http://monodevelop.com/Download
There is currently no official release of Monodevelop for windows. After researching it a little bit, it seems that MonoDevelop was started as a port of SharpDevelop which is an open source .Net IDE for windows. Perhaps you may want to look into SharpDevelop and see if it meets your needs.
You can find out more information at the SharpDevelop website:
http://www.icsharpcode.net/OpenSource/SD/
You can specifically target the Mono framework when writing apps in SharpDevelop (something you can't do with Visual Studio Express). I should have pointed this out in my answer above. From the website:
SharpDevelop has the ability to
compile your code against previous
versions of Microsoft's .NET
Framework, Microsoft's Compact
Framework or Mono (an open source
implementation of the .NET Framework
sponsored by Novell) if they are
installed.
The easiest way now to get MonoDevelop is running openSUSE Linux under VirtualBox. It's really no so hard. You will get "real" linux system with Mono & MonoDevelop running on it without any issues. Hope this helps.
There is not currently binaries available for MonoDevelop for Windows. This is because it has not been tested and is extremely buggy. Ie: you will probably not get more a minute or two of use before it crashes. Hopefully with MD 2.0 now out, this is something we will soon have time to address.
Note that you do not need MonoDevelop to use Mono. You can use the same binaries produced from Visual Studio or SharpDevelop on Mono.

Categories

Resources