这是我的CognitoSyncService
。当它尝试初始化CognitoSyncManager
时会收到错误
ArgumentException:需要配置有效的应用程序名称才能使用 此API。可以通过app.config或配置应用程序名称 通过设置Amazon.AWSConfigs.ApplicationName属性。
public class CognitoSyncService
{
readonly CognitoAWSCredentials _credentials;
readonly CognitoSyncManager _syncManager;
public CognitoSyncService(string IdentityPoolId, RegionEndpoint region)
{
if (string.IsNullOrEmpty(IdentityPoolId))
throw new ArgumentNullException("IdentityPoolId can not be null or empty.");
_credentials = new CognitoAWSCredentials(IdentityPoolId, region);
_syncManager = new CognitoSyncManager(_credentials, new AmazonCognitoSyncConfig { RegionEndpoint = region });
}
public void CreateDataset(string datasetName)
{
_syncManager.OpenOrCreateDataset(datasetName);
}
}
答案 0 :(得分:0)
这就是我解决问题的方法。
public CognitoSyncService(string IdentityPoolId, RegionEndpoint region)
{
if (string.IsNullOrEmpty(IdentityPoolId))
throw new ArgumentNullException("IdentityPoolId can not be null or empty.");
if (string.IsNullOrEmpty(AWSConfigs.ApplicationName))
AWSConfigs.ApplicationName = "my-application-name";
_credentials = new CognitoAWSCredentials(IdentityPoolId, region);
_syncManager = new CognitoSyncManager(_credentials, new AmazonCognitoSyncConfig { RegionEndpoint = region });
}