AWS Cognito在发布模式下不起作用,例外:“ AmazonCognitoIdentityProviderConfig的类型初始化程序”

时间:2018-10-08 09:50:38

标签: amazon-web-services xamarin

这是我第一次使用AWS服务,我读了很多东西,但找不到关于我的问题的答案,但没有用。我使用Xamarin,并且我的所有块都已更新。

我有一个仅在发布模式下才发生的问题。 我尝试在调试模式下注册用户,它可以正常工作,我创建了一个用户,在用户池中看到了它,并且与dynamoDB进行了交互。 在发行版中,我有此异常:

“'Amazon.CognitoIdentity.AmazonCognitoIdentityProviderConfig'的类型初始化程序引发了异常。”

我的App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
  </configSections>
  <aws region="us-west-2" profileName="xxxxx">
  </aws>
  <appSettings>
      <!-- AWS Cognito Identity Settings -->
      <add key="AWSProfileName" value="xxx"/>
      <add key="AWSRegion" value="eu-west-2"/>
      <add key="CLIENT_ID" value="xxxx" />
      <add key="USERPOOL_ID" value="eu-west-xxxx" />
      <add key="IDENTITYPOOL_ID" value="eu-west-2:x-x-x-x-xx" />
      <add key="IDENTITY_PROVIDER" value="cognito-idp.eu-west-2.amazonaws.com/" />
       <add key="ID_KEY" value="xxxx" />
        <add key="SECRET_KEY" value="xxxx" />
         <add key="AWS.S3.UseSignatureVersion4" value="true"/>
  </appSettings>
</configuration>

我的代码:

SignUpRequest signUpRequest = new SignUpRequest()
{
    ClientId = ConfigurationManager.AppSettings["CLIENT_ID"],
    Password = SubscribePagePassword.Text,
    Username = editUsername.Text
};

AttributeType emailAttribute = new AttributeType()
{
    Name = "email",
    Value = editadressemail.Text
};

AttributeType birthdateAttribute = new AttributeType()
{
    Name = "birthdate",
    Value = SubscribePageBirthday.Text
};

signUpRequest.UserAttributes.Add(emailAttribute);
signUpRequest.UserAttributes.Add(birthdateAttribute);

AnonymousAWSCredentials credentials = new AnonymousAWSCredentials();
var ConnectCognito = new AmazonCognitoIdentityProviderClient(credentials, RegionEndpoint.EUWest2);
var signUpResult = await ConnectCognito.SignUpAsync(signUpRequest);

预先感谢

0 个答案:

没有答案