Mono 3.0.0: Could not load file or assembly: System.Web.Extensions.dll, Version=4.0.0.0
apache, mod-mono, mono, servicestack
Solution
This error is caused because of an issue in the System.Configuration assembly for Mono's implementation of the .NET 4.0 framework when used by Mod_Mono / XSP. It's trying to read in the "MonoServerDefaultIndexFiles" appSetting key but can't find the Create factory method.
It took a a day or two to figure out that the solution is to edit the following file...
/opt/mono/bin/mod-mono-server4
...by changing the default value of 4.0 to 4.5 in this line:
exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/mod-mono-server4.exe" "$@"
With this resolved, the next issue i faced was with the fact that Mono replaces the built in AspNetMembershipProvider with a SqliteMembershipProvider through its Settings Map feature. I added the following line in my Web.config's appSettings section to disable this default behavior:
"<add key="MonoAspnetInhibitSettingsMap" value="disabled"/>"
After a couples days of chasing, my MVC3 app was successfully running on Mono 3.0.3 (latest at the time of this writing) / XSP 2.10 / Mod_Mono 2.10
Problem
I am hosting a ServiceStack web service in Apache with mod-mono, I have mono-3.0.0, and xsp-2.10.2. I hosted the hello world example targeting .Net framework 2.0 and using mod-mono-server2, and it worked fine. I then change the project to target .Net framework 4.0 and using mod-mono-server4. I get this error: Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in :0 at System.AppDomain.Load (System.String assemblyString) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string) at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in :0 at System.Web.Compilation.BuildManager.LoadAssembly (System.Web.Configuration.AssemblyInfo info, System.Collections.Generic.List`1 al) [0x00000] in :0 at System.Web.Compilation.BuildManager.GetReferencedAssemblies () [0x00000] in :0 at System.Web.Compilation.BuildManager.CallPreStartMethods () [0x00000] in :0 But the file System.Web.Extensions is installed in the GAC: gacutil -l System.Web.Extensions The following assemblies are installed into the GAC: System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Number of items = 3 Even if I set MonoPath to specifically get the 4.0 version the same error occurs: MonoPath /usr/local/lib/mono/4.0 I also noticed this: Version information: Mono Runtime Version: 2.10.5 (tarball Fri Oct 28 10:20:24 IST 2011); ASP.NET Version: 4.0.30319.1 Mono Runtime version says 2.10.5 although I have mono-3.0.0 installed, I don't know if this information has value for this issue. I tried running mod-mono-server4 directly and I got this error message: mod-mono-server4 mod-mono-server4 Missing method System.Configuration.IConfigurationSectionHandler::Create(object,object,XmlNode) in assembly /usr/local/lib/mono/4.0/System.dll, referenced in assembly /usr/local/lib/mono/4.0/System.Configuration.dll Exception caught during reading the configuration file: System.MissingMethodException: Method not found: 'System.Configuration.IConfigurationSectionHandler.Create'. at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0 at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0 at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in :0 at Mono.WebServer.Apache.Server.get_AppSettings () [0x00000] in :0 at Mono.WebServer.Apache.Server+ApplicationSettings..ctor () [0x00000] in :0 mod-mono-server4 Listening on: /tmp/mod_mono_server Root directory: /usr/local/bin Error: There's already a server listening on /tmp/mod_mono_server I googled for this error and it lead me to this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=7967 Maybe the error on mod-mono-server4 is the origin of the other bug... I will try to get xsp 3.0 and see if it solves the problem. Any ideas? Thanks