Running .NET 4 application with Mono - c#

I'm trying to run a .NET exe on a Ubuntu machine (I installed the package mono-complete), so far with no luck. The application is compiled with Visual C# Express 2010 under .NET 4 (Client Profile).
I try executing the program with the following command:
mono application.exe
However, I get the following error:
WARNING: The runtime version supported
by this application is unavailable.
Using default runtime: v1.1.4322
** (application.exe:5586): WARNING **: Missing method
System.Windows.Forms.Application::SetCompatibleTextRenderingDefault(bool)
in assembly
/usr/lib/mono/gac/System.Windows.Forms/1.0.5000.0__b77a5c561934e089/System.Windows.Forms.dll,
referenced in assembly
/media/disk/application.exe
Unhandled Exception:
System.MissingMethodException: Method
not found:
'System.Windows.Forms.Application.SetCompatibleTextRenderingDefault'.
It's suppose to be using .NET 4, not 1, but I don't know how to set it. I tried
mono --runtime=4.0.30319.1 application.exe
But that didn't work either.
Any help would be appreciated.

Sounds like you're experiencing this bug:
My Doc's Got No Nodes: .net 4 Client Profile on Mono 2.8
That is assuming you installed > Mono 2.8 (which was the first release to support .NET 4.0). If not, you should install a more recent Mono package.
The other thing to keep in mind is that Mono doesn't support the entirety of WinForms. Unless you developed your application with Mono in mind, there's a good chance you'll find that something you used isn't supported.

I suspect the exception is because the method System.Windows.Forms.Application.SetCompatibleTextRenderingDefault hasn't been implemented. Have you ran the tool through the Mono Migration Analyzer (MoMA), should help in knowing whether your application is compatible with mono. From that point you can possibly workaround the problem, maybe even incorporating the missing method in your code.

Current mono-complete package (even on Ubuntu Natty) uses mono 2.6.7 which doesn't support .NET 4.0 API. You'll have to build newest version of mono, which is the best way to get a chance of using 4.0 API. "Complete" support of .NET 4.0 is however planned in mono 3.0.

Install Monodevelop and just right click on the example.csprj that is a C#.NET project in linux and click on Monodevelop.

Related

Could not load file or assembly System, Version 2.0.0

I have a .NET application that currently builds and runs fine in a development environment but running the application on another machine is throwing this error.
The machine I am trying to run this on is running Windows Server 2012 which has .NET 4.5 baked into it. The error appears to be a .NET error however the GAC is showing the System Version 2.0.0.0 assembly installed. Also nothing is being written to Event Viewer on the application crash.
Any help or any idea of where to begin looking is appreciated.
Dan from above was correct, installing .NET 3.5 on the server fixed the error.
This link may possibly explain the error:
Make sure your .NET framework is patched.
It seems that the best explanation is that the server needs patched--but it could be the development machine as well.

How to run mixed C#/CLR/C++ solution downgraded to .Net 4.0?

I have solution with mixed projects: C#, native C++ and CLR/C++ (this also requires some external DLLs). When I used default settings of VS 2012 and targeted for .Net 4.5 it worked fine. But then I had to downgrade it to .Net 4.0.
I succeed by building solution only for 32-bit and forcing C# main project to be built for 32-bit also (usually C# is used for "Any CPU").
With such settings in runs fine on 2 computers out of 3 I have for tests -- meaning on it fails. It claims it cannot load CLR/C++ project or one of it dependencies.
So my problem is how to run it or at least to know what failed exactly? From the list of installed programs I can see that on working computer I have either .Net 4.5 Multi-Target or I don't have .Net 4.5 at all (only 4.0). On computer which fails I have .Net 4.5 (period). So maybe my program tries to load some assemblies from .Net 4.5 instead of 4.0? But that is just guessing.
Question -- how to diagnose such twisted solution and how to fix it?
Install .Net framework 4.0 multi-targeting pack
Check references (including NuGet, if any)
When I encounter a similar problem I usualy check the following:
Do you have Visual Studio installed on any of those three machines? I guess it's installed on the two where your application is running. If so, I'll extend the list later.
Check the target of the C++/CLI project - it should be Win32 if you build for 32-bit.
Run the application without Visual Studio, wait until it fails and go to the Event Viewer to look for some usefull information there.
Get Process Monitor, run the application without Visual Studio, wait until it fails, stop monitoring and filter the list by the application name and failed operations and look there for some usefull information.

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.

Mono for Android 4.0 Error compilation

I have updated the lates version of mono for android 4.0, and in the runtime itg gets me an Internal Error. Argument cannot be null. Parameter name: source.
How can I fix it?
What version of MonoDevelop are you running? Mono for Android 4.0 requires v2.8.4.1
http://android.xamarin.com/Releases/Mono_for_Android_4/Release_4.0.0
Edit: This was brought up on the mailing list today and is a bug:
This is a bug that's been identified today, and it's due to the project having external assembly references. While this is being fixed, disable "Fast Deployment" on the Project Options / Mono for Android Build panel.
This was just fixed in MonoDevelop 2.8.4.2.
Download from: http://monodevelop.com/Download

c# app compiled using mono on windows for a zero install solution?

HI,
I have a simple~ish command line app written in c#. I now need to use this on a server where I cannot install the dot net framework.
If I compile the app in Mono - will I be able to use it on a Windows server without the .net framework installed and without installing any mono-related files?
Hopefully just drop the exe in - and it will work?
MoMA (The mono migration analyzer) says the app is compatible with Mono.
Thanks
FrankB
Please see my answer to a similar question here. I haven't performed the operation myself, but it may be of some help to you.

Categories

Resources