System.Configuration.ConfigurationErrorsException: не удалось инициализировать систему конфигурации — CosmosC#

Место общения программистов C#
Ответить
Anonymous
 System.Configuration.ConfigurationErrorsException: не удалось инициализировать систему конфигурации — Cosmos

Сообщение Anonymous »

Когда я пытаюсь инициализировать свой клиент Cosmos в фоновой рабочей службе, я получаю сообщение об ошибке.

Код: Выделить всё

Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
\---\> System.MissingMethodException: Cannot dynamically create an instance of type  'System.Configuration.ClientConfigurationHost'. Reason: No parameterless constructor defined.
at System.RuntimeType.ActivatorCache..ctor(RuntimeType)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean)
at System.Configuration.Internal.ConfigSystem.System.Configuration.Internal.IConfigSystem.Init(Type, Object\[\] )
at System.Configuration.ClientConfigurationSystem..ctor()
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
\--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(String)
at System.Configuration.ConfigurationManager.get_AppSettings()
**at Microsoft.Azure.Cosmos.DocumentClient.Initialize**(Uri, ConnectionPolicy , Nullable`1 , HttpMessageHandler , ISessionContainer , Nullable`1 , IStoreClientFactory , TokenCredential , String , RemoteCertificateValidationCallback , CosmosClientTelemetryOptions )
at Microsoft.Azure.Cosmos.DocumentClient..ctor(Uri, AuthorizationTokenProvider, EventHandler`1, ConnectionPolicy , Nullable`1 , JsonSerializerSettings , ApiType , EventHandler`1 , HttpMessageHandler , ISessionContainer , Nullable`1 , Func\`2 , IStoreClientFactory , Boolean , String , RemoteCertificateValidationCallback , CosmosClientTelemetryOptions , AvailabilityStrategy , IChaosInterceptorFactory )
at Microsoft.Azure.Cosmos.ClientContextCore.Create(CosmosClient, CosmosClientOptions)
at Microsoft.Azure.Cosmos.CosmosClient..ctor(String, AuthorizationTokenProvider, CosmosClientOptions)
Мой фрагмент кода

Код: Выделить всё

var endPoint = "https:/endpoint-URI:443/";
var key = "api-Key";

CosmosClient cosmosClient = new CosmosClient(endPoint,key); // i get error here
var databaseName = "dbName";
var containerName = "containerName";
var container = cosmosClient.GetContainer(databaseName, containerName);
var upsertOrder = new
{
id = new Guid(),
Partition = "",
Ticker = "ABC"
};
var response = await container.CreateItemAsync(item: upsertOrder)
Я должен иметь возможность инициализировать доступ клиента Cosmo к данным


Подробнее здесь: https://stackoverflow.com/questions/790 ... m-failed-t
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»