authentication failing -- mono 3.1.2 #126

Closed
dterei opened this Issue Jul 18, 2013 · 0 comments

2 participants

@dterei

Hi,

Trying to use SASL authentication with the latest pull of Enyim fails on OS X using Mono 3.1.2 (also tried with 2.10).

I'm trying to run the DemoApp from the source tree. I've modified the App.config to be:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
        <sectionGroup name="enyim.com">
            <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
        </sectionGroup>
    </configSections>

    <enyim.com>
        <memcached protocol="Binary">
            <servers>
                <add address="127.0.0.1" port="11211" />
            </servers>
            <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00" />
            <authentication type="Enyim.Caching.Memcached.PlainTextAuthenticator, Enyim.Caching" 
                userName="user-1" password="pass" zone="AUTHZ"/>
        </memcached>
    </enyim.com>

    <log4net>
        <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout,log4net">
                <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
            </layout>
        </appender>
        <root>
            <level value="Debug" />
            <appender-ref ref="ConsoleAppender" />
        </root>
    </log4net>

</configuration>

And the program.cs file simply contains:

using System;
using System.Net;
using Enyim.Caching;
using Enyim.Caching.Configuration;
using Enyim.Caching.Memcached;

namespace DemoApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var mc = new MemcachedClient ();

            for (var i = 0; i < 100; i++)
                mc.Store(StoreMode.Set, "Hello", "World");

            var raw = mc.Get("Hello");
        }
    }
}
            Console.WriteLine(raw);

The error I get is:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Enyim.Caching.MemcachedClient ---> System.InvalidOperationException: Property 'userName' not found in configuration element
  at System.Configuration.ConfigurationElement.set_Item (System.String property_name, System.Object value) [0x00043] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:240 
  at System.Configuration.ConfigurationElement.set_Item (System.Configuration.ConfigurationProperty property, System.Object value) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:220 
  at Enyim.Caching.Configuration.AuthenticationElement.OnDeserializeUnrecognizedAttribute (System.String name, System.String value) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00167] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:321 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x0038d] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:387 
  at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x000d7] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSection.cs:185 
  at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSection.cs:193 
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x000db] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/Configuration.cs:305 
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00032] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs:67 
  at System.Configuration.Configuration.GetSection (System.String path) [0x0006a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/Configuration.cs:261 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:162 
  at Enyim.Caching.MemcachedClient..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at DemoApp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Enyim.Caching.MemcachedClient ---> System.InvalidOperationException: Property 'userName' not found in configuration element
  at System.Configuration.ConfigurationElement.set_Item (System.String property_name, System.Object value) [0x00043] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:240 
  at System.Configuration.ConfigurationElement.set_Item (System.Configuration.ConfigurationProperty property, System.Object value) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:220 
  at Enyim.Caching.Configuration.AuthenticationElement.OnDeserializeUnrecognizedAttribute (System.String name, System.String value) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00167] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:321 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x0038d] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs:387 
  at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x000d7] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSection.cs:185 
  at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSection.cs:193 
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x000db] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/Configuration.cs:305 
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00032] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs:67 
  at System.Configuration.Configuration.GetSection (System.String path) [0x0006a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/Configuration.cs:261 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:162 
  at Enyim.Caching.MemcachedClient..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at DemoApp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
The application was terminated by a signal: SIGHUP

I found that if I modify the file Configuration/AuthenticationElement.cs, to change the function OnDeserializeUnrecognizedAttribute from:

        protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
        {
            var property = new ConfigurationProperty(name, typeof(string), value);
            base[property] = value;
            this.parameters[name] = value;
            return true;
        }

to remove the single line base[property] = value;. That this fixes the error and SASL works great! I.e., new function is:

        protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
        {
            var property = new ConfigurationProperty(name, typeof(string), value);
            this.parameters[name] = value;
            return true;
        }

Not sure if this is due to OSX and Mono, I don't have a windows box so can't say.

@enyim enyim added the wontfix label Apr 24, 2016
@enyim enyim closed this Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment