Running NET SDK under Linux/Mono
I have just spent a nice morning trying to get NET SDK working under Linux (CentOs 5/6)/Mono(2.10.8)
There were some snags along the way but finally it worked. I'd like to share my experience in case someone else tries the same.
First of all. Don't use app.config/web.config to configure Couchbase client.
I will give an error (see https://github.com/enyim/EnyimMemcached/issues/57)
Rather than that use:
var cf = new CouchbaseClientConfiguration();
cf.Urls.Add(new Uri("http://127.0.0.1:8091/pools/default"));
var c = new CouchbaseClient(cf);
and you'll be fine.
Second step: make sure you use the same runtime version for couchbase/enyim as your program.
Couchbase downloads provide 3.5, so you should compile with gmcs rather than dmcs.
If you really need dmcs you'll have to recompile the NET SDK from source (quite easy).
* Tip for Couchbase - it'd greatly help mono users if you provided the SDK compiled for the 4.0 runtime
Third problem lies in mono itself. There is now a bug in mono (https://bugzilla.xamarin.com/show_bug.cgi?id=4242) that affects JSON serialization/deserialization if your culture uses coma rather than dot for decimal point.
TO go around this problem set Thread.CurrentThread.CultureInfo or change you default culture (LANG=en_US prior to running mono).
Hope it helps you save some time :)
Cheers!
Michal
I've just done similar, setup Couchbase 2.0beta and .NET Client SDK 1.2 beta with mono under Mac OS X. I want to share my experiences, too:
1) Using App.config is still broken (will give out "factory required" exception). Don't use it, but use the code-config approach given by the OP.
2) make sure to run mono 3.0 (which is beta currently). With mono 2.10.9 I get a "Missing method System.Net.ServicePoint.SetTcpKeepAlive" exception.
3) make sure you set your .NET profile to 4.0 in MonoDevelop, since the .NET Couchbase SDK 1.2 is in 4.0, too.
There is quite some work to be done for Couchbase 1.2 .NET SDK to work out-of-the-box with mono, but I am sure the couchbase developers will dedicate some love to it.
P.S: Great talk about couchbase at the monkeyspace conference which got me curious, and thanks for the free couchbase shirt ;)
Hi John, has 1.1 patch (for .net 3.5 apps) for 1.2 client been released ? if yes where can I find it ? I need a .net 3.5 bin release because of Sharepoint 2010 integration (with Couchbase) which doesn't support .net 4.0 in the same appdomain.
Thanks in advance,
Giuseppe
PS: I need urgently take a decision about using Couchbase or directly memcached, THX
Hi Giuseppe.
Are you looking for a 3.5 build that's Mono compatible or that has the fixes from 1.2? The 1.1 release is 3.5, but does not have a number of bug fixes that are available in 1.2. Unfortuntaely, there are a number of 4.0 dependencies in the 1.2 client that would make a 3.5 release a challenge.
-- John
I've started developing using Couchbase 2.0 with .NET Client 1,2, The server runs on Ubuntu 12.04 LTS and works fine. I've verified it with a local php client and from a Windows 7 networked box using a .NET app using the 1.2 client. I had created the .NET test program so it would run under Mono. A very simply program fails on Linux when it's creating the CouchbaseClient(). this is with the mono dlls. The line using (var cbx = new CouchbaseClient()) fails.
I debugged with monodevelop on the Linux box. used a different App.config for the ip address). The problem on the Linux box appears to be Factory must be Defined. This is using the Enyim memcached dll (the mono version), so most likely needs a config setting according to error reports I've seen. The stack trace is:
Enyim.Caching.Configuration.FactoryElement`1[[Couchbase.Configuration.ICouchbasePerformanceMonitorFactory, Couchbase, Version=1.2.0.0, Culture=neutral, PublicKeyToken=05e9c6b5a9ec94c2]].CreateInstance () in
Couchbase.Configuration.CouchbaseClientSection.Couchbase.Configuration.ICouchbaseClientConfiguration.CreatePerformanceMonitor () in
Couchbase.CouchbaseClient..ctor (pool={Couchbase.CouchbasePool}, configuration={Couchbase.Configuration.CouchbaseClientSection}) in
Couchbase.CouchbaseClient..ctor (configuration={Couchbase.Configuration.CouchbaseClientSection}, bucketName="", bucketPassword=(null)) in
Couchbase.CouchbaseClient..ctor (configuration={Couchbase.Configuration.CouchbaseClientSection}) in
Couchbase.CouchbaseClient..ctor () in
gvmake.Program.CreateCity (args={string[0]}) in /var/gv/gvmake/gv2/Main.cs:46
The Client 1.2 pdf has several settings for this but none seem to work. My Ubuntu App.Config is like this with better indentation.
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</configSections>
<couchbase>
<servers>
<add uri="http://127.0.0.1:8091/pools/"/>
</servers>
</couchbase>
</configuration>
The uri in the Windows app.config used pools/default but that makes no difference on Ubuntu. Do you have an example of a working app.config? Thanks!
David Bolton
Hi Michal,
Thanks for sharing your experience!
When the 1.2 client is released (with server 1.2) it will be .NET 4.0. I'm going be releasing a patch to 1.1 soon and will look into including a 4.0 and 3.5 build with that.
I've had other requests to get the client working with Mono on Linux, so I will be looking into that in the weeks ahead.
-- John