C# VS2010 program compiling + running on Linux MONO - c#

I have a c# program I wrote. I want to run it on Mono on CentOS 6. What are the steps I need to take to compile it? I read some steps using xbuild which I could not get to work, some steps using gmcs, etc. Nothing working right now.
A simple and to the point guide would be good. I ran it through a Mono Analyzer and it did not give any errors for Mono, so it should be good to go.

Well you shouldn't have to special compile it at all as long as it doesn't have a GUI (meaning it's just a console app), or that GUI is a simple Windows Forms or GTK#. Mono will run a regular C# program on the console just fine. There is some quirkiness with Windows Forms, which was never fully finished, but generally you should just be able to compile using VS 2010, copy the dll's and executables to the system you want to run it on, and run 'mono myprogram.exe'. We run several older programs we have this way.

To run a .net program under mono all you have to do is to copy the .exe file with all depending dlls to the mono machine and run the application with:
mono myprogram.exe
if this doesn't work, something with your code doesn't work with mono/Linux.
As you mentioned in a comment, you got some IO errors, that could be because you trying to connect to COM1 or something like that. COM doesn't exist in Linux, as I'm sure other stuff doesn't either (I'm a very beginner with Linux ^^).
Maybe you should try to Console.WriteLine() at some points off your code. That's a good way to "debug" without debugger ^^

Related

monodevelop - working debug but not working release

I have developed a project with VS on Windows 10. Right now on Linux mint i am debugging the project with MonoDevelop and it runs just fine.
Let me show you:
However when i make a build and i go to the Release folder and then i try from the terminal to launch the program i have a problem. Let me show you first the files i have build:
Then i go to the directory with my terminal and i run:
chmod +x ./WorldServer.exe then i run ./WorldServer.exe
and i receive the following error:
I know that this is .exe file and maybe i have to build a different type of file. But i am not really sure what setting should i apply in my project to make a working build for linux.
As far as i know linux is using .so as extension for it's libraries. However it is generating .dll files. Can i change that? Can i somehow make my project to be "buildable" in the two OS Linux and Windows ?
The exception tells us, you need System.Management in your project. It isn't there.
Why?
Because Mono, according to there Road-map, doesn't support this:
The following do not map to operating systems other than Windows, and
we are unlikely to spend time to support them even on Windows:
System.Management
How?
System.Management is a library that only works on Windows. The MySQL connector driver has started to depend on this library and tries to load it per reflection.
I'm not into this whole MySql Progess but there is an open bug for it. Also there is a comment which says:
The last working version of the MySQL .NET Driver is 6.4.6
I hope this helps you.

C# exe running issue with EMGU CV

I have been working on Microsoft Visual C# 2010 for an image processing program. The software uses EMGU CV 2.4.0. The program is very long (consists of 8 very lengthy functions) so i cannot post it here. Now, the program works perfectly on my pc. I have finished it. I can just run the exe file, and it works. My problem is that the .exe file doesnt work on another computer. Actually, I have 2 separate projects, But both are using EMGU CV. No error message shows to me when I run the first exe on another pc ( although it shows to me sometimes that ( project1 stopped working, windows is trying to collect information, this might take minutes ) but that's not always. Now the error message that shows to me when i run the second exe on another pc is (microsoft .net framework, EMGU.CV.CVInvoke exception error). then the exe work and a window appear ( which is expected ) but the real task of the program which is doing some image processing is not being done.
Note that both of the projects are windows applications output type.
Note that .NET framework 4 client profile is the target framework
I don't think this is .NET framework issue. Because I have tried to do a simple program and the exe file works on the other pc (it was just a simple streamwriter program which creates .txt) These are the EMGU CV libraries I'm using:
EMGU.CV.dll
EMGU.CV.GPU.dll
EMGU.CV.UI.dll
EMGU.CV.UTIL.dll
Just for your information, I have downloaded EMGU CV 2.4.0 on the other pc as well ( after failing in running it with putting the libraries with the .exe in 1 file ) but still nothing works. I have no clue what on earth can be the problem!
I don't know if this is useful, but the program uses SURFFEATURE example as the one in the EMGU CV but with lots and lots of modifications ( I have worked on it since the last Novermber) and basically it is a program for object recognition purpose.
have you installed the Visual C++ redistributibale on the machine, you are trying to run the file on?
If it's a x64 machine you will need the x64 version. But I would still also install the x86 version, just in case...
I know that this is an old question but..
If your OS is 64 bit you should use EmguCV x64 but if your OS is 32 bit then use x86 dlls. I built my solution as 'Any CPU' and it still worked.
Also as #Pogo the Jotz mentioned, you need to install Visual C++ Redistributable on that machine, same as on your visual studio version in which you compiled your exe file. The .Net framework also should be the same.

How can I run a C# program on my school's Linux server?

I would like to write a program in C# on Visual Studio on my windows computer and then upload it to my school's Linux server and run the program there. Assignments are turned in via this server: my professor receives the file and runs it from his directory. Is this possible and if so how can I do it?
I read about Mono but from my understanding of it, Mono is used to write and run C# applications on Linux so if it's not on my school's server then I would't be able to run the application. So even if I uploaded a copy of Mono to my personal directory on the server, my professor wouldn't be able to run the program from his directory. Is this correct?
I would like to know if there is any way to do this with or without Mono.
Edit: The professor will be running the program like this:
$p1 testfile
where "testfile" is a command line argument being passed to my program. "p1" will probably be a script that I'll write to run the program.
I would suggest first checking to see if your school's Linux machines have mono already installed. Check the lib folder and see if there's a mono folder. The directory may not line up exactly, but it should be something along this line:
/usr/local/lib/mono/ ; various things here
If the school system doesn't have mono, I would ask the professor to have the system admin install mono on one or more machines. If that isn't possible then I would go down the route of packaging it yourself.
Check out the Mono project here.
you can bundle your compiled application with the required runtime files so the app can be run without having a mono runtime installed, but you should test it out before giving it them and it would just be easier to have your professor install mono.
read: http://www.mono-project.com/Guide:Running_Mono_Applications

Compiling moonlight application on Mac OS X

I'm using MonoDevelop 2.8.5 and I'm trying to compile a moonlight application, but it fails. I created a brand new Moonlight Application Project and tried to compile it, but it fails with the following error.
Error: Framework 'Moonlight / Silverlight 4.0' not installed. (MoonlightTest)
In this question from October 2011 one of the developers of MonoDevelop states that is not possible to do this without some major hassle.
Is this still true with the new version(s) of MonoDevelop out?
If so, how can I compile Moonlight Application Projects in MonoDevelop if I'm willing to go through some hassle?
This is a bit of "psychic debugging" but I've run into it a lot in linux and imagine you might have the same problem happening on OS X. Is the compiler that Monodevelop is looking for exactly the same as the version you installed? It might be something as simple as the folder being called Moonlight1.3 vs Moonlight1.3.1. Look at the build output and see what version it is looking for then look in your applications folder (via terminal the app folder in the finder might hide the info) and check that they are the same.

C# WinForms App won't run on Win7 after Building

I have a program that I built that reads and writes files. I built it in Release mode, then tried to run the exe on Win7. At first, with troubleshooting on, Windows simply told me the application closed and it was looking for a solution. After a few seconds, the dialog would disappear and show nothing more.
So with some significant effort I got the debugger attached to the process, but it was only showing me disassembly, which tells me that the error taking place wasn't in my application code, but in the framework somewhere.
The strange thing is that when I let the debugger attach, then press "stop" in VS, and exit the debugger, the program actually runs at that point!
So now I'm stumped. I have an application that builds, that seems to be having a permission error when I run it, but if I let the debugger attach then close it, it runs, and there's no Exception to really look at.
How I troubleshoot this issue?
Edit: Responding to Merlyn:
It's a custom app written from scratch in c#. The only dependency it has outside of core .NET namespaces is the Ionic.Zip DLL.
Visual Studio 2008 (Writing in C# 3.5)
Windows 7 - Home Premium, v6.1 build 7600
CPU - x64 quad core
CPU are you compiling under: Any CPU
I haven't tried it on another machine or a different version of VS.
Edit: I was able to try the compiled version on another win7 computer, and it worked without issue, so it looks like a security (?) issue on my computer only.
Try it in the debugger with Just My Code disabled and Native Code enabled, then check the call stack.
Also, what happens if you run it directly in Visual Studio?
Uncheck Enable Visual Studio Hosting Process in Project Properties and see whether it still works in VS.
I'd suggest sending the issue to Microsoft support. Especially with the data given here, you will have an easy time convincing them it's their problem. You might need an MSDN subscription for that.

Categories