Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to target .NET 4.0 under mono

Tags:

.net

mono

I have mono 2.10 installed which is said to support 4.0 i have a site running, a simple hello world that is built (i develop in on a windows box with vs 2010 and then upload to a linux box) with 3.5.

I want to put the site under 4.0. I changed it on visual studio and on the windows box it works. on linux i have the error

Unrecognized attribute 'targetFramework'

SO, which steps are needed to change the target from 3.5 to 4.0?

EDIT: Am not using monodevelop.

Am creating the site on a windows machine with visual studio and then copying the entire website folder to the linux box. After that i open the site url and thats it.

WHen should i run the dmcs compiler? AFAIK the site is compiled automatically when it runs for the first time ?

like image 825
sergio Avatar asked Sep 29 '11 14:09

sergio


2 Answers

Although it is correct that you use dmcs to compile .NET 4 apps on Mono, I do not think that this is your problem. It sounds to me like you are trying to serve a compiled ASP.NET app on Linux.

Your problem is probably that you need to call mod-mono-server4 from Apache but are likely running mod-mono-server2. You should have a line in your httpd.conf or mod-mono.conf that looks like the following:

MonoServerPath default /usr/bin/mod-mono-server4

Check out this page, specifically the troubleshooting section. The instructions are a little dated so you have to change the digit '2' to '4' but it is a good explanation of what is going on. This page might also help you setup the right configuration.

like image 67
Justin Avatar answered Jan 04 '23 12:01

Justin


Using mono 2.10, you either run dmcs or gmcs -sdk:4 when compiling your code.

like image 20
IanNorton Avatar answered Jan 04 '23 13:01

IanNorton