Mono winforms on linux

How do I install mono’s System.Windows.Forms on Ubuntu?

What are the other Mono dependencies besides mono-runtime and libmono-system-windows-forms4.0-cil required to run C# Windows Forms applications on Ubuntu Linux 16.04? Thank you.

4 Answers 4

So you’re looking for a package containing a file called System.Windows.Forms.dll . You can search:

  • on your machine: apt-file search System.Windows.Forms.dll (the apt-file package must be installed)
  • online: at packages.ubuntu.com.

Both methods lead you to (as of Ubuntu 14.04):

sudo apt-get install libmono-system-windows-forms4.0-cil 

What are the other Mono dependencies besides mono-runtime and libmono-system-windows-forms4.0-cil required to run C# Windows Forms applications on Ubuntu Linux 16.04? Thank you.

Open Synaptic and search for System.Windows.Forms and select libmono-winforms2.0-cil or libmono-winforms1.0-cil and then apply.

(optional) You might need to install System.Runtime package as well. just search for that and install libmono-system-runtime2.0-cil or libmono-system-runtime1.0-cil

% apt-get install libmono-winforms1.0-cil libmono-winforms2.0-cil 

Open the references menu, Typing in the left upper size of MonoDevelop’s GUI the Word Reference. It’ll open a window. There you’ll be able to enable the reference System.Windows.Forms . As it’s enabled, you’ll be able to declare in your code:

and use it as well. This answer assumes that you’ve done all the previous in this page.

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.12.43529

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

Читайте также:  Linux close tcp connection

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Running Windows Forms on Linux with Mono

Although WinForms may be “dead”, it does have one trick up its sleeve that WPF doesn’t, and that is you can run WinForms apps on mono. Here’s a simple guide to running a Windows Forms application on Ubuntu

Step 1 — Install Mono

Open a terminal window, and make sure everything is up to date with the following commands:

Now you can install mono with the following command:

Step 2 — Create an Application

Now we need to create our C# source file. You can use any text editor you like, but if like me you aren’t familiar with Linux text editors like vi or emacs, gedit is a simple notepad-like application which is easy to use. Launch it with the following command: (the ampersand at the end tells the terminal not to wait for gedit to close before letting us continue)

Now let’s create a very simple application:

Step 3 — Compile and Run

Now we’re ready to compile. The C# compiler in mono is gmcs. We’ll need to tell it we’re referencing the Windows Forms DLL:

To run the application, simply call mono, passing in the executable:

And that’s all there is to it! We have a WinForms app running on Linux.

Although mono doesn’t support everything in WinForms, you can use most standard controls, so you can easily add further UI elements:

Taking it Further

Obviously writing applications by hand like this is a bit cumbersome, but there is an IDE you can use for Linux called monodevelop. You install it like this:

This then gives you a nice editing environment, allowing you to debug, and manage project references (you’d usually add System.Windows.Forms and System.Drawing). Unfortunately it doesn’t offer a WinForms designer – for desktop apps it prefers you to use GTK#. Nevertheless, it’s a nice free IDE allowing you to experiment with getting your existing Windows Forms applications working cross-platform on Linux. (It seems this will also work on OS X with mono installed but I don’t have a Mac so I haven’t tried it out)

Читайте также:  Seeing all users in linux

Want to learn more about Windows Forms? Be sure to check out my Pluralsight course Windows Forms Best Practices.

Comments

Comment by Bahawal TV

Can I run an existing application developed using deveX gui components?
That will be great if I can do that.

About Mark Heath

Microsoft MVP

I’m a Microsoft MVP and software developer based in Southampton, England, currently working as a Software Architect for NICE Systems. I create courses for Pluralsight and am the author of several open source libraries. I currently specialize in architecting Azure based systems and audio programming. You can find me on:

Search this site

Keep Updated

My Pluralsight Courses

  • Microservices Fundamentals
  • LINQ Best Practices
  • Microsoft Azure Developer: Deploying and Managing Containers
  • Azure Functions Fundamentals
  • Azure Durable Functions Fundamentals
  • Microservices Architecture: Executive Briefing
  • Building Microservices
  • Dapr 1 Fundamentals
  • Create Serverless Functions
  • More Effective LINQ
  • Versioning and Evolving Microservices in ASP.NET Core
  • Microsoft Azure Developer: Implement Azure Functions (AZ-204)
  • Azure Container Instances: Getting Started
  • Building Serverless Applications in Azure
  • Azure CLI: Getting Started
  • Understanding and Eliminating Technical Debt
  • Windows Forms Best Practices
  • Digital Audio Fundamentals
  • UWP Audio Fundamentals
  • Audio Programming with NAudio
  • Understanding Distributed Version Control Systems
  • Creating Modern WPF Applications with MahApps.Metro
  • Creating and Selling a Digital Product
  • ClickOnce Deployment Fundamentals

My Open Source Software

  • NAudio
  • NLayer
  • NAudio.Sharp Media Foundation
  • WaveForm Renderer
  • WPF WaveForm
  • TypeScript Tetris
  • Skype Voice Changer
  • MIDI File Mapper
  • MIDI File Splitter
  • SilverNibbles
  • Asterisk
  • WPF Shapes
  • .NET Voice Recorder

Archives

Tags

  • Azure (150)
  • NAudio (100)
  • Advent of Code (81)
  • LINQ (79)
  • F# (70)
  • Azure Functions (67)
  • C# (63)
  • Azure CLI (45)
  • WPF (39)
  • audio (38)
  • XAML (38)
  • JavaScript (36)
  • Silverlight (34)
  • Pluralsight (27)
  • Docker (26)
  • MoreLINQ (26)
  • Durable Functions (25)
  • Azure Blob Storage (20)
  • Azure Service Bus (17)
  • Azure Container Instances (15)

Источник

It is possible to run winforms app in ubuntu?

I have an application written on top of .Net framework 4.5 and C# using Visual Studio 2015 Community . I created it in Win10 OS in 64 bit machine. Is there any possibilities to run this application in Ubuntu ? Then how can I compile the application to make it compatible for ubuntu machine? I would like to deploy it as a cross-platform application but I have a hard time figuring out the best way. I heard about Mono but I am not yet familliar with the IDE. Please help.

Читайте также:  Статический ip linux консоль

I think it’s impossible, becouse WinForms is a wrapper over WinAPI functions, which may have no analog in Ubuntu.

That’s bad to hear, but i found winforms application created in Mono and they say that it can also run in ubuntu. My problem for this approach is i dont know how to compile my application in Mono to work in ubuntu.

But it refers that you can create a winforms application using Mono but i dont want to start from the beginning. The biggest of my problem encounter is how can i compile my application to make it compatible for ubuntu. tsk

2 Answers 2

Unless you’re using special .NET classes or native libraries it should be possible and easy.

Since the .NET compiled executables are built on bytecode, they aren’t linked to a specific platform and Mono has been designed with this in mind.

Supposing you’ve just tested an application named «WindowsApplication», try to follow these steps:

Check under your Visual Studio projects folder, try to locate your WindowsApplication.exe. Check «C:\Users\YourName\Documents\Visual Studio\Projects\WindowsApplication\WindowsApplication\bin\Debug (or Release)

After installing Mono on your Ubuntu system check if the mono command is available in your folder (for this test just use your home dir):

username@locahost ~ $ mono —version Mono JIT compiler version 5.0.1 (Visual Studio built mono) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: normal (more output)

Copy your program executable from Windows into the Ubuntu folder, let’s suppose you copied to the directory where you just tested mono.

Launch it by typing: mono ./WindowsApplication1.exe (if it’s in your current directory) or mono //WindowsAppliction.exe

In case it didn’t run you can download the «Mono Migration Analyzer» (MoMA), which is a tool specifically designed to identify unresolved dependencies and help you solve the problem.

Источник

Оцените статью
Adblock
detector