gpt4 book ai didi

.net - 使用 .net 连接器连接 Couchbase 服务器时出现异常

转载 作者:搜寻专家 更新时间:2023-10-30 23:40:10 25 4
gpt4 key购买 nike

我在使用 .Net SDK 连接 couchbase 集群(服务器)时出现异常,使用最新的 .net 连接器用于 Couchbase 服务器。附加 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 - 使用 .net 连接器连接 Couchbase 服务器时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35967010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com