Since the recent release of Ubuntu 14.04 I was surprised to see a new version of MonoDevelop, so I wanted to try creating an ASP.NET MVC 3 (Razor) project but it failed and threw the following exception:
System.IO.FileNotFoundException:Could not find file "/usr/lib/monodevelop/AddIns/MonoDevelop.AspNet.Mvc/Templates/Common/Index.cshtml".File name:'/usr/lib/monodevelop/AddIns/MonoDevelop.AspNet.Mvc/Templates/Common/Index.cshtml'
So while searching on the Internet for hours I found the following solution and hope this will solve your problem too.
Download and Build MonoDevelop
First remove MonoDevelop from Ubuntu:
sudo apt-get remove monodevelop
Before you can build you will need to following components installed:
sudo apt-get install git automake gtk-sharp2 gnome-sharp2 mono-xsp4
Clone the latest source code from GitHub, build and install it:
git clone https://github.com/mono/monodevelop.git cd monodevelop ./configure --profile=stable sudo make sudo make install
Create and set permission to the following directory for mono:
sudo mkdir /etc/mono/registry sudo mkdir /etc/mono/registry/LocalMachine sudo chmod g+rwx /etc/mono/registry sudo chmod g+rwx /etc/mono/registry/LocalMachine
Create an ASP.NET MVC 3 (Razor) Project
Run MonoDevelop and create a new ASP.NET MVC 3 (Razor) project and then change the default .NET Framework 4.0 to 4.5 in your project’s options under General.
And now remove the following broken references in your project’s reference folder in red (System.Web.Helpers and System.Web.WebPages):
Now to fix those references that we just delete you will need to go to Nuget and install the Microsoft ASP.NET Web Pages package:
Now go to your project’s Web.config file and remove or comment out the following line in the <appSettings>:
<add key="webpages:Version" value="1.0.0.0" />
Open the Global.asax.cs file and make sure the following references are added:
using System.Web.Mvc; using System.Web.Routing; using System.Web.WebPages.Scope; using System.Reflection;
Now add the Application_BeginRequest() method to the MvcApplication class in the Global.asax.cs file:
protected void Application_BeginRequest() { var ob = typeof(AspNetRequestScopeStorageProvider).Assembly.GetType("System.Web.WebPages.WebPageHttpModule").GetProperty("AppStartExecuteCompleted",BindingFlags.NonPublic | BindingFlags.Static); ob.SetValue(null, true, null); }
Now you should be able to press F5 to run and see the following message on the page.
Welcome to ASP.NET MVC on Mono!
I hope this information is useful to everyone please leave a comment if any of the instructions don’t work for you and I will do my best to help you out.
Most of this worked very well for me. Had to do some workarounds for security problems outlined here, but thanks regardless.
Thanks Gunnar I have corrected the post.
Really like the clear instructions – unfortunately the compile/make of the stable version didnt work for me so attempting “http://askubuntu.com/questions/450654/installing-monodevelop-from-ppa-on-ubuntu-14-04-trusty”. Thanks for your post great format, Barney 🙂
Hi David! Thanks a lot for your post!
but could you help me?
during installation I always get this error
Errors:
/home/nikolay/monodevelop/main/Main.sln (default targets) ->
(Build target) ->
/home/nikolay/monodevelop/main/src/addins/NUnit/NUnitRunner/NUnitRunner.csproj (default targets) ->
(BeforeBuild target) ->
/home/nikolay/monodevelop/main/src/addins/NUnit/NUnitRunner/NUnitRunner.csproj: error : Command ‘mono /home/nikolay/monodevelop/main//external/nuget-binary/NuGet.exe restore -SolutionDirectory /home/nikolay/monodevelop/main/’ exited with code: 1.
78 Warning(s)
1 Error(s)
Hi Nikolay
Can you tell me the commands that you have entered prior to receiving this error message?
David.
Yes, of course! It is going on, after I enter “sudo make”.
Thank you, for your attention!
Hi Nikolay
I haven’t come across this error, but did you try these steps in this order:
Yes, I tried. But it doesn’t matter… always get the same error.
Anyway, thanks!
I have a same error
Right after changing the PERMISSIONS, I didn’t know how to run MonoDevelop.
Could it be that I also get Nikolay’s errors and that prevents the script to create an Icon?
How do I run MonoDevelop if I cannot find an Icon?
Rodolfo
Try rebooting your machine after a successful build, I had the same problem and couldn’t find the icon until I rebooted.
Hi David
Thanks for these instructions – by far the least painful version of the process I’ve seen. However, I too ran into the errors Nikolay reports – with the nuget part – but I found the answer here –
http://stackoverflow.com/questions/24793207/error-when-compiling-monodevelop-5-3-on-linux
It’s to do with root security certificates and I solved it as described on SO with this utility –
http://linux.die.net/man/1/mozroots
Hope that helps someone.
Daniel
In my case, when I install from github and fire MonoDevelop the option ASP.NET MVC3 disappears when creating a new project. When I install it from Ubuntu repository I get ASP.NET MVC3 option for a new project but get the error you described here:
System.IO.FileNotFoundException:Could not find file “/usr/lib/monodevelop/AddIns/MonoDevelop.AspNet.Mvc/Templates/Common/Index.cshtml”.File name:’/usr/lib/monodevelop/AddIns/MonoDevelop.AspNet.Mvc/Templates/Common/Index.cshtml’
# sudo apt-get remove monodevelop
# sudo apt-get install git automake gtk-sharp2 gnome-sharp2 mono-xsp4
# git clone https://github.com/mono/monodevelop.git
# cd monodevelop
# ./configure –profile=stable
# mozroots –import –sync
# sudo make
# sudo make install
# make run
Excellent post! Just had to do one more thing to make it work here:
mono external/nuget-binary/NuGet.exe restore Main.sln
Source: http://stackoverflow.com/questions/24793207/error-when-compiling-monodevelop-5-3-on-linux
When I get to the ‘sudo make’ part, I get the error output:
nuget restore
/bin/bash: nuget: command not found
make[2]: *** [restore-packages] Error 127
make[2]: Leaving directory `/tmp/monodevelop/main’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/monodevelop/main’
make: *** [all-recursive] Error 1
I had to edit vi /tmp/monodevelop/main/Makefile.am
and change the line:
nuget restore
with:
mono /tmp/monodevelop/main/external/nuget-binary/NuGet.exe restore
The whole thing then goes like this:
WARNING: Error: SendFailure (Error writing headers)
Installing ‘Newtonsoft.Json 6.0.8’.
Installing ‘Microsoft.AspNet.Razor 3.2.2’.
Installing ‘NUnit 2.6.4’.
Installing ‘SharpSvn.1.8-x86 1.8013.3576.94’.
Installing ‘SharpZipLib 0.86.0’.
Installing ‘Microsoft.AspNet.Mvc 5.2.2’.
Installing ‘Microsoft.AspNet.WebPages 3.2.2’.
Installing ‘LibGit2Sharp.NativeBinaries 1.0.51’.
ERROR building certificate chain: System.ArgumentException: certificate —> System.Security.Cryptography.CryptographicException: Unable to decode public key. —> System.NullReferenceException: Object reference not set to an instance of an object
at System.Security.Cryptography.X509Certificates.PublicKey..ctor (Mono.Security.X509.X509Certificate certificate) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PublicKey () [0x00000] in :0
— End of inner exception stack trace —
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PublicKey () [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.Process (Int32 n) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain (X509ChainStatusFlags flag) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in :0
— End of inner exception stack trace —
at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in :0
at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in :0
Please, report this problem to the Mono team
Installing ‘Microsoft.Web.Infrastructure 1.0.0.0’.
Successfully installed ‘Microsoft.AspNet.Razor 3.2.2’.
Successfully installed ‘NUnit 2.6.4’.
ERROR building certificate chain: System.ArgumentException: certificate —> System.Security.Cryptography.CryptographicException: Unable to decode public key. —> System.NullReferenceException: Object reference not set to an instance of an object
at System.Security.Cryptography.X509Certificates.PublicKey..ctor (Mono.Security.X509.X509Certificate certificate) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PublicKey () [0x00000] in :0
— End of inner exception stack trace —
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PublicKey () [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.PrepareForNextCertificate (Int32 n) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain (X509ChainStatusFlags flag) [0x00000] in :0
at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in :0
— End of inner exception stack trace —
at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in :0
at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in :0
Please, report this problem to the Mono team
Successfully installed ‘SharpZipLib 0.86.0’.
Successfully installed ‘Microsoft.AspNet.Mvc 5.2.2’.
Successfully installed ‘Microsoft.Web.Infrastructure 1.0.0.0’.
Successfully installed ‘Microsoft.AspNet.WebPages 3.2.2’.
Successfully installed ‘Newtonsoft.Json 6.0.8’.
Successfully installed ‘SharpSvn.1.8-x86 1.8013.3576.94’.
Successfully installed ‘LibGit2Sharp.NativeBinaries 1.0.51’.
Unable to find version ‘2.6.4’ of package ‘NUnit.Runners’.
make[2]: *** [restore-packages] Error 1
make[2]: Leaving directory `/tmp/monodevelop/main’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/monodevelop/main’
make: *** [all-recursive] Error 1
I then restarted the whole process as root and edited as commented above after make failed with nuget. Ran make again and I got:
wrapper/WidgetEventHandler.cs(10,3): error CS0246: The type or namespace name `Gtk’ could not be found. Are you missing an assembly reference?
wrapper/WidgetEventHandler.cs(12,27): error CS0246: The type or namespace name `Gtk’ could not be found. Are you missing an assembly reference?
wrapper/WidgetEventHandler.cs(25,10): error CS0246: The type or namespace name `Gtk’ could not be found. Are you missing an assembly reference?
TopLevelWindow.cs(10,3): error CS0246: The type or namespace name `Gdk’ could not be found. Are you missing an assembly reference?
TopLevelWindow.cs(24,10): error CS0246: The type or namespace name `Gdk’ could not be found. Are you missing an assembly reference?
TopLevelDialog.cs(10,3): error CS0246: The type or namespace name `HButtonBox’ could not be found. Are you missing an assembly reference?
TopLevelDialog.cs(11,3): error CS0246: The type or namespace name `VBox’ could not be found. Are you missing an assembly reference?
TopLevelDialog.cs(12,3): error CS0246: The type or namespace name `HSeparator’ could not be found. Are you missing an assembly reference?
TopLevelDialog.cs(25,10): error CS0246: The type or namespace name `HButtonBox’ could not be found. Are you missing an assembly reference?
TopLevelDialog.cs(29,10): error CS0246: The type or namespace name `VBox’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(62,36): error CS0246: The type or namespace name `GLib’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(62,66): error CS0246: The type or namespace name `NotifyHandler’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(68,39): error CS0246: The type or namespace name `GLib’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(68,54): error CS0246: The type or namespace name `NotifyHandler’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(73,39): error CS0246: The type or namespace name `GLib’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(73,71): error CS0246: The type or namespace name `NotifyHandler’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(78,39): error CS0246: The type or namespace name `GLib’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(78,69): error CS0246: The type or namespace name `NotifyHandler’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(84,42): error CS0246: The type or namespace name `GLib’ could not be found. Are you missing an assembly reference?
wrapper/NotifyWorkaround.cs(84,57): error CS0246: The type or namespace name `NotifyHandler’ could not be found. Are you missing an assembly reference?
editor/GtkWorkarounds.cs(38,43): error CS0246: The type or namespace name `Gdk’ could not be found. Are you missing an assembly reference?
editor/GtkWorkarounds.cs(43,43): error CS0246: The type or namespace name `Gdk’ could not be found. Are you missing an assembly reference?
editor/GtkWorkarounds.cs(73,40): error CS0246: The type or namespace name `Gtk’ could not be found. Are you missing an assembly reference?
editor/GtkWorkarounds.cs(225,10): error CS0246: The type or namespace name `Gdk’ could not be found. Are you missing an assembly reference?
93 Warning(s)
751 Error(s)
Time Elapsed 00:00:13.8553090
make[2]: *** [sln_build] Error 1
make[2]: Leaving directory `/tmp/monodevelop/main’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/monodevelop/main’
make: *** [all-recursive] Error 1
Seems that the following link has the solution to the above:
http://stackoverflow.com/questions/22744041/error-while-compiling-monodevelop-4-2-2-from-tarball-in-ubuntu
Simply:
cd /usr/lib/mono/gac/
sudo gacutil -i glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll &&
sudo gacutil -i atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll &&
sudo gacutil -i gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll &&
sudo gacutil -i gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll &&
sudo gacutil -i glade-sharp/2.12.0.0__35e10195dab3c99f/glade-sharp.dll &&
sudo gacutil -i pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll &&
sudo gacutil -i gnome-sharp/2.24.0.0__35e10195dab3c99f/gnome-sharp.dll &&
sudo gacutil -i gconf-sharp/2.24.0.0__35e10195dab3c99f/gconf-sharp.dll &&
sudo gacutil -i gnome-vfs-sharp/2.24.0.0__35e10195dab3c99f/gnome-vfs-sharp.dll
After this was done ‘make’ worked successfully. Then also ‘make install’ worked as it should.
Hello,
before build you can also run:
sudo apt-get install libssh-1-dev nuget
and install the newest mono by this guild: http://www.mono-project.com/docs/getting-started/install/linux/