使用 .net 连接器连接 Couchbase 服务器时出现异常
Exception while connecting Couchbase server using .net connectors
我在使用 .Net SDK
、最新的 .net connectors for Couchbase server
连接 couchbase cluster
(服务器)时出现异常。附加 C# 代码和 App.config.
异常:
"An unhandled exception of type
'System.Configuration.ConfigurationErrorsException' occurred in
System.Configuration.dll Additional information: Unrecognized
attribute 'OperationLifeSpan'. Note that attribute names are
case-sensitive."
如果我在这里遗漏了什么,请帮助我,
C#代码:
public static void CreateOrder()
{
using (var cluster = new Cluster("couchbaseClients/couchbase"))
{
IBucket bucket = null;
try
{
bucket = cluster.OpenBucket();
var order = new Document<Order>()
{
Id = Guid.NewGuid().ToString(),
Content = new Order()
{
Name="Tiffin",
Location="WITP",
Quantity=2
}
};
var result = bucket.Insert(order);
if (result.Success)
Console.WriteLine("Order Created '{0}'", order.Id);
}
finally
{
if (bucket != null)
cluster.CloseBucket(bucket);
}
}
}
配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="couchbaseClients">
<section name="couchbase"
type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient"/>
</sectionGroup>
</configSections>
<couchbaseClients>
<couchbase useSsl="false" operationLifeSpan="1000">
<servers>
<add uri="http://192.168.56.101:8091/pools"></add>
<add uri="http://192.168.56.102:8091/pools"></add>
<add uri="http://192.168.56.103:8091/pools"></add>
<add uri="http://192.168.56.104:8091/pools"></add>
</servers>
<buckets>
<add name="default" useSsl="false" password="" operationLifespan="2000">
<connectionPool name="custom" maxSize="10" minSize="5" sendTimeout="12000"></connectionPool>
</add>
</buckets>
</couchbase>
</couchbaseClients>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
您在 operationLifespan 中使用大写字母 S 而不是小写字母 s。
尝试
<couchbase useSsl="false" operationLifespan="1000">
而不是
<couchbase useSsl="false" operationLifeSpan="1000">
我在使用 .Net SDK
、最新的 .net connectors for Couchbase server
连接 couchbase cluster
(服务器)时出现异常。附加 C# 代码和 App.config.
异常:
"An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll Additional information: Unrecognized attribute 'OperationLifeSpan'. Note that attribute names are case-sensitive."
如果我在这里遗漏了什么,请帮助我,
C#代码:
public static void CreateOrder()
{
using (var cluster = new Cluster("couchbaseClients/couchbase"))
{
IBucket bucket = null;
try
{
bucket = cluster.OpenBucket();
var order = new Document<Order>()
{
Id = Guid.NewGuid().ToString(),
Content = new Order()
{
Name="Tiffin",
Location="WITP",
Quantity=2
}
};
var result = bucket.Insert(order);
if (result.Success)
Console.WriteLine("Order Created '{0}'", order.Id);
}
finally
{
if (bucket != null)
cluster.CloseBucket(bucket);
}
}
}
配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="couchbaseClients">
<section name="couchbase"
type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient"/>
</sectionGroup>
</configSections>
<couchbaseClients>
<couchbase useSsl="false" operationLifeSpan="1000">
<servers>
<add uri="http://192.168.56.101:8091/pools"></add>
<add uri="http://192.168.56.102:8091/pools"></add>
<add uri="http://192.168.56.103:8091/pools"></add>
<add uri="http://192.168.56.104:8091/pools"></add>
</servers>
<buckets>
<add name="default" useSsl="false" password="" operationLifespan="2000">
<connectionPool name="custom" maxSize="10" minSize="5" sendTimeout="12000"></connectionPool>
</add>
</buckets>
</couchbase>
</couchbaseClients>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
您在 operationLifespan 中使用大写字母 S 而不是小写字母 s。
尝试
<couchbase useSsl="false" operationLifespan="1000">
而不是
<couchbase useSsl="false" operationLifeSpan="1000">