How to run MVC application with newer Mono in Debi

2019-08-27 02:35发布

问题:

Latest release of Mono was installed in Debian 9.3 using

cd /usr/local/src
wget https://github.com/mono/libgdiplus/archive/5.6.1.tar.gz
tar -xvf 5.6.1.tar.gz
cd libgdiplus-5.6.1
mkdir /opt/m518
apt-get install  libtool autoconf glib-2.0
./autogen.sh --prefix=/opt/m518
make
make install

apt-get install git autoconf libtool automake build-essential gettext cmake python
git clone --recursive https://github.com/mono/mono.git --branch=mono-5.18.1.0

cd mono
./autogen.sh --prefix=/opt/m518
make
make install

cd /usr/local/src
wget https://github.com/mono/xsp/archive/4.6.tar.gz
tar xf 4.6.tar.gz
apt-get install libtool-bin
cd xsp-4.6
./autogen.sh --prefix=/opt/m518
make
make install

Apche conf file was changed to

MonoServerPath "/opt/m518/bin/mod-mono-server4"

Trying to run MVC application causes exception

[Fri Mar 29 23:26:57.643727 2019] [mpm_event:notice] [pid 28163:tid 140067959029824] AH00489: Apache/2.4.25 (Debian) mod_mono/3.12 configured -- resuming normal operations
[Fri Mar 29 23:26:57.643846 2019] [core:notice] [pid 28163:tid 140067959029824] AH00094: Command line: '/usr/sbin/apache2'
[ERROR] FATAL UNHANDLED EXCEPTION: System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.MissingMethodException: Method 'string.Split' not found.
  at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs:273 
  at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ce] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:572 
  at System.Configuration.Configuration.Load () [0x00043] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:532 
  at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0005d] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:138 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00056] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:96 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00038] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000d] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/InternalConfigurationFactory.cs:41 
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x000ea] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:119 
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0000e] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:49 
   --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0001f] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:52 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:159 
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in /usr/local/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:173 
  at Mono.WebServer.Options.Settings.Setting`1[T]..ctor (System.String name, Mono.WebServer.Options.Settings.Parser`1[T] parser, System.String description, System.String appSetting, System.String environment, System.Nullable`1[T] defaultValue, System.String prototype) [0x000c5] in /usr/local/src/xsp-4.6/src/Mono.WebServer/Options/Settings/Setting.cs:55 
  at Mono.WebServer.Options.Settings.NullableSetting`1[T]..ctor (System.String name, Mono.WebServer.Options.Settings.Parser`1[T] parser, System.String description, System.String appSetting, System.String environment, System.Nullable`1[T] defaultValue, System.String prototype) [0x00003] in /usr/local/src/xsp-4.6/src/Mono.WebServer/Options/Settings/NullableSetting.cs:33 
  at Mono.WebServer.Options.Settings.NullableUInt16Setting..ctor (System.String name, System.String description, System.String appSetting, System.String environment, System.Nullable`1[T] defaultValue, System.String prototype) [0x00000] in /usr/local/src/xsp-4.6/src/Mono.WebServer/Options/Settings/NullableUInt16Setting.cs:35 
  at Mono.WebServer.Apache.ConfigurationManager..ctor (System.String name, System.Boolean quietDefault, System.String rootDefault) [0x0009c] in /usr/local/src/xsp-4.6/src/Mono.WebServer.Apache/ConfigurationManager.cs:43 
  at Mono.WebServer.Apache.Server.RealMain (System.String[] args, System.Boolean root, Mono.WebServer.IApplicationHost ext_apphost, System.Boolean v_quiet) [0x0001a] in /usr/local/src/xsp-4.6/src/Mono.WebServer.Apache/main.cs:77 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool)
  at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00034] in /usr/local/src/xsp-4.6/src/Mono.WebServer.Apache/main.cs:58 

How to run MVC application in newer Mono ? If Apache conf file contains

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

so that Mono shipped with Debian is used, it works. Also it works with 5.4.1.6 version, if

git clone --recursive https://github.com/mono/mono.git --branch=mono-5.4.1.6

is used.

I also compiled xsp from mono/xsp master branch and added System namespace and compilation element to application web.config:

<pages controlRenderingCompatibilityVersion="4.0">
  <namespaces>
    <add namespace="System.Linq" />
    <add namespace="Eeva.Business" />
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.WebPages" />
    <add namespace="System" />
  </namespaces>
</pages>

<compilation debug="true" targetFramework="4.7">
  <assemblies>
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

to but problem persists.