2

I've successfully installed Membase Server, their "Sub-millisecond access latency" feature is actually forced me to write this question, otherwise I would ten times already switched to MongoDB. So the question: I have properly installed and configured my Membase Server now I want my .NET client application to get access to this database, for this purpose I'm using their Enyim .NET Client. I have written the following test application:

using System;
using System.Linq;
using System.Diagnostics;

using Membase;
using Membase.Configuration;

namespace CouchDB
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var config = new MembaseClientConfiguration()
            {
                Bucket = "helloworld",
                BucketPassword = "123",
                NodeLocator = typeof(Enyim.Caching.Memcached.DefaultNodeLocator),
                Transcoder = new Enyim.Caching.Memcached.DefaultTranscoder(),
                KeyTransformer = new Enyim.Caching.Memcached.TigerHashKeyTransformer(),
                PerformanceMonitorFactory = null // I'm on Mac OS X
            };

            config.SocketPool.MinPoolSize = 10;
            config.SocketPool.MaxPoolSize = 20;
            config.SocketPool.DeadTimeout = TimeSpan.FromSeconds(10);
            config.SocketPool.ConnectionTimeout = TimeSpan.FromSeconds(5);
            config.Urls.Add(new Uri("http://localhost:8091/pools/default"));

            var client = new MembaseClient(config);


            var spoon = client.Get<String>("Spoon");

            Console.WriteLine(spoon);
        }
    }
}

The problem occurs when I'm trying to create a client, exception occurs which doesn't even show complete stack, tells only

"Cannot cast from source type to destination type"

at System.Web.Script.Serialization.JavaScriptSerializer..ctor(resolver=null, registerConverters=false)

Lu4
  • 14,873
  • 15
  • 79
  • 132
  • One thing that I can see that is incorrect here is that you are specifying a bucket called helloworld in the config, but trying to connect to a bucket called default in your connect string. I am not very familiar with the Enyim Client, but if you are having trouble your better off starting with the examples on the Couchbase website. I know there is a configuration file you can use. Once you get that working you can tweak the settings to fit your particular project. – mikewied Aug 11 '11 at 23:07
  • Sorry for the two comments. You also mention that your using the Membase couchDB in the question and then in the description you said your using Membase server. Can you be more specific? Couchbase offers Couchbase single which is their version of CouchDB, Membase server which is the product that offers the sub-millisecond latencies, and then there is the Couchbase server with is CouchDB and Membase put together. If you can specify which you are using I can better help you with your problem. – mikewied Aug 11 '11 at 23:11
  • Hi, Sorry for the clutter, I've tried to use Membase Server, though now I think I don't understand anything, I've created another question here http://stackoverflow.com/questions/7040980/membase-can-someone-explain-the-idea-behind-their-technology I would appreciate any help. Thank you! – Lu4 Aug 12 '11 at 13:49

1 Answers1

1

I've spent some hours on this problem. There is a bug in the Mono runtime (it's still present in 2.10.5 AFAIK), that causes a conflict between two versions of System.Web.Extensions : 3.5 and 4.0

The DLL provided for Membase client (and now Couchbase client) are linked with the 3.5 version. I don't know what references the 4.0 version, but still, something does. So the solution is either to apply a redirection (I haven't tested it) :

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions"
                          publicKeyToken="31bf3856ad364e35"
                          culture="neutral" />
        <bindingRedirect oldVersion="3.5.0.0"
                         newVersion="4.0.0.0"/>
     </dependentAssembly>
  </assemblyBinding>
</runtime>

Or recompile the client (that's what I've done). There are two minor problems when compiling the client under mono : in MemcachedNode.cs, there is an explicit implementation of the Failed event. Since it is unnecessary (there is no other conflicting Failed event implemented), you can just remove the lines. Also there is a SetTcpKeepAlive that you can remove (I think it's safe).

  • Update : if you compile the latest couchbase-client branch (release11 as of june 2012), the Hammock Library has disapeared, so there is no need for the removal of SetTcpKeepAlive – GuillaumePitel Jun 29 '12 at 08:10