aws / aws-sdk-net

The official AWS SDK for .NET. For more information on the AWS SDK for .NET, see our web site:
http://aws.amazon.com/sdkfornet/
Apache License 2.0
2.07k stars 861 forks source link

The type initializer for 'Amazon.AWSConfigs' threw an exception #1079

Closed swath24 closed 5 years ago

swath24 commented 6 years ago

Hi all,

I am trying to connect to amazon dynamodb through .net. and ended up in this error.

An error has occurred. The type initializer for 'Amazon.AWSConfigs' threw an exception. I am attaching my code and config file. Any help would be greatly appreciated. >
> > ` AWSCredentials credentials = new StoredProfileAWSCredentials("default"); using (AmazonDynamoDBClient client = new AmazonDynamoDBClient(credentials, RegionEndpoint.APSoutheast1)) { string tableName = "ProductCatalog"; var request = new CreateTableRequest { TableName = tableName, AttributeDefinitions = new List() { new AttributeDefinition { AttributeName = "Id", AttributeType = "N" } }, KeySchema = new List() { new KeySchemaElement { AttributeName = "Id", KeyType = "HASH" //Partition key } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 10, WriteCapacityUnits = 5 } }; var response = client.CreateTable(request); } `
klaytaybai commented 6 years ago

Hi @swath24, thank you for letting us know you have a problem. Are you able to provide an InnerException for this or any other details?

jayd16 commented 5 years ago

I'm seeing a similar issue with the static constructor for Awsconfigs.

NullReferenceException: Object reference not set to an instance of an object Amazon.CSMSection.get_CSMEnabled () Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section) Amazon.Util.Internal.RootConfig..ctor () Amazon.AWSConfigs..cctor ()

bvgwi commented 5 years ago

I'm getting a similar error, but related to Amazon Pinpoint. Using .NET Core 2.1, Framework 4.7.1, on a Windows 2016 server. Does anyone know of a solution to fix this for Windows Server?

`Details

Error Message: Exception has been thrown by the target of an invocation. Source: mscorlib Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateConfig(Type serviceInterfaceType, AWSOptions options) at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateServiceClient(ILogger logger, Type serviceInterfaceType, AWSOptions options) at Amazon.Extensions.NETCore.Setup.AWSOptions.CreateServiceClient[T]() at [XXXXXXXX].VerifyPhoneNumber(String phoneNumber) --- Inner Exception --- Error Message: The type initializer for 'Amazon.AWSConfigs' threw an exception. Source: AWSSDK.Core Stack Trace: at Amazon.AWSConfigs.get_LoggingConfig() at Amazon.Runtime.ClientConfig..ctor() at Amazon.Pinpoint.AmazonPinpointConfig..ctor() --- Inner Exception --- Error Message: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Source: mscorlib Stack Trace: at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl) at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence() at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType) at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType) at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate) at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type) at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed) at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType) at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate) at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type) at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext() at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext() at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName) at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath) at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Amazon.AWSConfigs.GetSection[T](String sectionName) at Amazon.Util.Internal.RootConfig..ctor() at Amazon.AWSConfigs..cctor() `

aqiao commented 10 months ago

Hi @klaytaybai ,noted this issue closed, may i know if it's fixed, if so, could you share the details