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 к данным
Когда я пытаюсь инициализировать свой клиент Cosmos в фоновой рабочей службе, я получаю сообщение об ошибке. [code]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) [/code] Мой фрагмент кода [code]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) [/code] Я должен иметь возможность инициализировать доступ клиента Cosmo к данным