We have the following code:
var couchbaseConfiguration =
(CouchbaseClientSection) ConfigurationManager.GetSection(configurationSectionName);
couchbaseClientConfiguration = new ClientConfiguration(couchbaseConfiguration);
This code works fine on Windows however, in Visual Studio Community, it does not. It throws a TypeLoadException when trying to figure out what Serializer, Converter, and Transcoder are. What is going on in ClientConfiguration.cs
here https://github.com/couchbase/couchbase-net-client/blob/release27/Src/Couchbase/Configuration/Client/ClientConfiguration.cs#L302-L311:
//transcoders, converters, and serializers...o mai.
Serializer = definition.Serializer != null
? SerializerFactory.GetSerializer(definition.Serializer)
: SerializerFactory.GetSerializer();
Converter = definition.Converter != null
? ConverterFactory.GetConverter(definition.Converter)
: ConverterFactory.GetConverter();
Transcoder = definition.Transcoder != null
? TranscoderFactory.GetTranscoder(this, definition.Transcoder)
: TranscoderFactory.GetTranscoder(this);
The defintion.X
all wind up coming out in the debugger as undefined.
I have a workaround:
try
{
couchbaseClientConfiguration = new ClientConfiguration(couchbaseConfiguration)
{
Servers = alteredServers
};
}
catch (TypeLoadException e)
{
// Workaround for Visual Studio Community / Mac that doesn't process these correctly
// When the name and type are empty, under the covers the ClientConfiguration
if ((couchbaseConfiguration.Serializer.Name == "") && (couchbaseConfiguration.Serializer.Type == ""))
{
couchbaseConfiguration.Serializer = new SerializerElement();
}
if ((couchbaseConfiguration.Converter.Name == "") && (couchbaseConfiguration.Converter.Type == ""))
{
couchbaseConfiguration.Converter = new ConverterElement();
}
if ((couchbaseConfiguration.Transcoder.Name == "") && (couchbaseConfiguration.Transcoder.Type == ""))
{
couchbaseConfiguration.Transcoder = new TranscoderElement();
}
couchbaseClientConfiguration = new ClientConfiguration(couchbaseConfiguration)
{
Servers = alteredServers
};
}
EDIT: even though this seems to work, it looks like I cannot connect to a bucket…
Complains: “Could not bootstrap with CCCP. (Could not find: )” I think this is related to the connection pool not initializing…
Then Complains: {Couchbase.Configuration.CouchbaseBootstrapException: After bootstrapping the nodes list has zero elements indicating that client failed during bootstrapping. Please check the client logs for more information as for why it failed. at Couchbase.Configuration.C…}