2

I am trying to migrate an ASP.Net (2.0) VB web app from a SLES 11 server to a new SLES 12 server. Unfortunately, mono is no longer supported by Novell / SUSE / NetIQ folk.

This is my first time developing for a mono / mod_mono Apache combination. It has been quite a learning experience. I am not sure if I have everything (mono versions / repos / configs) lined-up properly. A lot has changed since Visual Studio 2008. I am hoping an ex-Novell or other mono expert can help me get things straitened out.

So, after much effort, I have managed to get a somewhat working solution, but I cannot seem to encrypt the web.config. Instead of producing an encrypted web.config connectionStrings section, the protect call eats most of the file, and gives the error page with the following message

System.Xml.XmlException

Root element is missing.

no wonder as the web config is reduced to ...

<?xml version="1.0" encoding="utf-8"?>
<configuration><appSettings>
  </appSettings></configuration>

from

?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
  </appSettings>
  <connectionStrings>
    <add name="websalesConnectionString" connectionString="server=192.168.85.15;User Id=zzzz;password=zzzz;Persist Security Info=True;database=websales" providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <system.web>
    <authentication mode="Windows" />
    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
    <compilation debug="true" strict="false" explicit="true">
      <assemblies>
        <add assembly="*" />
      </assemblies>
    </compilation>
    <customErrors mode="Off" />
    <pages>
      <namespaces>
        <clear />
        <add namespace="System" />
        <add namespace="System.Collections" />
        <add namespace="System.Collections.Generic" />
        <add namespace="System.Collections.Specialized" />
        <add namespace="System.Configuration" />
        <add namespace="System.Text" />
        <add namespace="System.Text.RegularExpressions" />
        <add namespace="System.Web" />
        <add namespace="System.Web.Caching" />
        <add namespace="System.Web.SessionState" />
        <add namespace="System.Web.Security" />
        <add namespace="System.Web.Profile" />
        <add namespace="System.Web.UI" />
        <add namespace="System.Web.UI.WebControls" />
        <add namespace="System.Web.UI.WebControls.WebParts" />
        <add namespace="System.Web.UI.HtmlControls" />
      </namespaces>
    </pages>
  </system.web>
</configuration>

Here is the method that is called to do the encryption (file eating)

Public Sub webencrypt(ByVal lEncrypt As Boolean)
    Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
    Dim configSection As ConfigurationSection = config.GetSection("connectionStrings")
    If lEncrypt Then
        If Not configSection.SectionInformation.IsProtected Then
            configSection.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider")
            config.Save()
        End If
    End If          
End Sub

I have tried code from: http://www.developersalley.com/blog/post/2011/11/22/How-To-Protect-Webconfig-File.aspx

and from: http://devproconnections.com/aspnet/encrypting-configuration-file-sections

Version Info

  • Apache2 (2.4.16)
  • Apache2-mod-mono (3.12-1)
  • Mono (4.2.2.30)
  • ASP.Net (2.0)

mod-mono-serverX.exe

Another mystery is that mod-mono-server2.exe errors are appearing in the apache log. Why is mod-mono-server2.exe (its wrapper in /usr/bin) being called ?

Cannot open assembly '/usr/lib/mono/2.0/mod-mono-server2.exe': No such file or directory.

I specifically use the apache mod_mono directive MonoServerPath to call mod-mono-server4.exe.

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

Which calls

/usr/lib/mono/4.5/mod-mono-server4.exe

that points to

mod-mono-server4.exe -> ../gac/mod-mono-server4/4.2.0.0__0738eb9f132ed756/mod-mono-server4.exe

mod-mono-server2.exe is not installed with the latest mono AFAIK. Many combinations / tests are required to figure this out as the docs still refer to mod-mono-server for ASP 1 and mod-mono-server2 for ASP 2 .... and not a word about mod-mono-server4.

I can ignore the errors and / or re-point the mono wrappers to all point to mod-mono-server4 ... but that feels wrong too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.