【发布时间】:2016-05-06 05:28:57
【问题描述】:
我是 couchbase 数据库的新手,我第一次尝试编写代码连接到远程 couchbase 服务器。我用 C# 编写了一个控制台应用程序,其中有一个 app.config 文件和 program.cs 文件。
我的app.config文件如下
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<configSections>
<sectionGroup name="couchbaseClients">
<section name="couchbase"
type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient"/>
</sectionGroup>
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<couchbaseClients>
<couchbase useSsl="false" operationLifeSpan="1000">
<servers>
<add uri="http://xxx.xxx.xxx.xxx:8091/pools"></add>
<add uri="http://xxx.xxx.xxx.xxx:8091/pools"></add>
</servers>
<buckets>
<add name="default" useSsl="false" Username="xxxxxx" password="xxxxx" operationLifespan="2000">
<connectionPool name="custom" maxSize="10" minSize="5" sendTimeout="12000"></connectionPool>
</add>
</buckets>
</couchbase>
</couchbaseClients>
</configuration>
而我的Program.cs文件如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Couchbase;
using Enyim.Caching.Memcached;
using Newtonsoft.Json;
using System.Configuration;
namespace CouchBase_ConnectionTester
{
class Program
{
static void Main(string[] args)
{
using (var cluster = new Cluster("couchbaseClients/couchbase"))
{
using (var bucket = cluster.OpenBucket())
{
}
}
}
}
}
当我尝试调试代码时,它会在代码行抛出错误
using (var cluster = new Cluster("couchbaseClients/couchbase"))
错误信息如下
“Couchbase.Cluster”的类型初始化器抛出异常。
内部异常如下
从配置部分“common/logging”获取 Common.Logging 的配置失败
请帮助我。提前感谢
【问题讨论】: