Closed phamt closed 9 years ago
Hi:
Remove all references to the assemblies provided by the Nuget package or the compiled binaries folder, as those will be updated on tomorrow.
Next, open the Xamarin iOS project (not iOS Classic) in your IDE, and compile. Make sure that you have the Conditional compilation directives there if you switch from Debug to Release.
Take the AWS_MOBILE assembly from this and add it to your references and recompile you code.
Let me know if this resolves your issue.
Thanks, TEW
Sent from my Windows Phone
From: phamtmailto:notifications@github.com Sent: 3/5/2015 7:12 AM To: awslabs/aws-sdk-xamarinmailto:aws-sdk-xamarin@noreply.github.com Subject: [aws-sdk-xamarin] Unable to create an instance of CognitoAWSCredentials with Xamarin iOS test app (#19)
I have a Xamarin iOS (unified api) test app that is trying to create some test data but I am able to to create an instance of CognitoAWSCredentials with a ArgumentNull Exception. on the "stream" parameter. I tried both using the latest Nuget packages as well as using the latest binaries with no luck.
Here's the sample code and stacktrace:
Amazon.Runtime.AWSCredentials credentials = new CognitoAWSCredentials ("xxxxxxx",
"us-east-1:xxxxx-xxxxx-xxxx-xxxx-xxxxxx",
"arn:aws:iam::xxxxx:role/Cognito_DefaultIdentityPoolAuth_DefaultRole",
"arn:aws:iam::xxxxx:role/Cognito_DefaultIdentityPoolAuth_DefaultRole", RegionEndpoint.USEast1);
System.ArgumentNullException: Argument cannot be null.
Parameter name: stream
at System.IO.StreamReader.Initialize (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00199] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:255
at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen) [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:166
at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:152
at System.IO.StreamReader..ctor (System.IO.Stream stream) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:139
at Amazon.RegionEndpoint.LoadEndpointDefinitionsFromEmbeddedResource () [0x00000] in
Reply to this email directly or view it on GitHub: https://github.com/awslabs/aws-sdk-xamarin/issues/19
I am still seeing the issue. I've removed all references to the Nuget packages. I am using the AWSSDK_XMOBILE.dll from Compiled Binaries_Assemblies/iOS Unified API. And I am running in debug mode.
Recompiling the project and using the output binary fixed the issue.
I am now getting a "AmazonClientException: No RegionEndpoint or ServiceURL configured" exception trying to set some test data:
using(var syncClient = new AmazonCognitoSyncClient(credentials))
{
var recordsResult = await syncClient.ListRecordsAsync (new ListRecordsRequest {
DatasetName = "myDataSet",
});
var updateRequest = new UpdateRecordsRequest {
DatasetName = "myDataset",
RecordPatches = new List<RecordPatch>
{
new RecordPatch
{
Op = Operation.Replace,
SyncCount = 0,
Key = "myKey",
Value = "myValue"
}
},
SyncSessionToken = recordsResult.SyncSessionToken
};
var result = await syncClient.UpdateRecordsAsync (updateRequest);
}
Amazon.Runtime.AmazonClientException: No RegionEndpoint or ServiceURL configured at Amazon.Runtime.ClientConfig.Validate () [0x00021] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.Runtime/ClientConfig.cs:395 at Amazon.Runtime.AmazonServiceClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.Runtime.ClientConfig config) [0x00034] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.Runtime/AmazonServiceClient.cs:76 at Amazon.CognitoSync.AmazonCognitoSyncClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.CognitoSync.AmazonCognitoSyncConfig clientConfig) [0x00000] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.CognitoSync/AmazonCognitoSyncClient.cs:89 at Amazon.CognitoSync.AmazonCognitoSyncClient..ctor (Amazon.Runtime.AWSCredentials credentials) [0x00002] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.CognitoSync/AmazonCognitoSyncClient.cs:68
The SDK you built should be AWSSDK_XMOBILE.dll not AWSSDK_iOS. The error shows AWSSDK_iOS, is that the name of your assembly. In the assembly manifest on Github the assembly to be created is noted as AWSSDK_XMOBILE. Was this changed or altered somehow?
Sent from Windows Mail
From: phamt Sent: Thursday, March 5, 2015 2:52 PM To: 'awslabs/aws-sdk-xamarin' Cc: Tara Walker
Recompiling the project and using the output binary fixed the issue.
I am now getting a "AmazonClientException: No RegionEndpoint or ServiceURL configured" exception trying to set some test data:
using(var syncClient = new AmazonCognitoSyncClient(credentials))
{
var recordsResult = await syncClient.ListRecordsAsync (new ListRecordsRequest {
DatasetName = "myDataSet",
});
var updateRequest = new UpdateRecordsRequest {
DatasetName = "myDataset",
RecordPatches = new List<RecordPatch>
{
new RecordPatch
{
Op = Operation.Replace,
SyncCount = 0,
Key = "myKey",
Value = "myValue"
}
},
SyncSessionToken = recordsResult.SyncSessionToken
};
var result = await syncClient.UpdateRecordsAsync (updateRequest);
}
Amazon.Runtime.AmazonClientException: No RegionEndpoint or ServiceURL configured at Amazon.Runtime.ClientConfig.Validate () [0x00021] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.Runtime/ClientConfig.cs:395 at Amazon.Runtime.AmazonServiceClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.Runtime.ClientConfig config) [0x00034] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.Runtime/AmazonServiceClient.cs:76 at Amazon.CognitoSync.AmazonCognitoSyncClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.CognitoSync.AmazonCognitoSyncConfig clientConfig) [0x00000] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.CognitoSync/AmazonCognitoSyncClient.cs:89 at Amazon.CognitoSync.AmazonCognitoSyncClient..ctor (Amazon.Runtime.AWSCredentials credentials) [0x00002] in /AWS.XamarinSDK/AWSSDK_iOS/Amazon.CognitoSync/AmazonCognitoSyncClient.cs:68
— Reply to this email directly or view it on GitHub.
The name of the assembly is still AWSSDK_XMOBILE.
The stacktrace just happens to resolve the source code to my local disk where the assembly was built from.
I should have looked at your code more closely. Your error was not that the code did not find a Regional Endpoint, you did not set a Regional Endpoint which is required for all AWS Services.
Example:
AmazonCognitoSyncConfig awsCognitoConfig;
awsCognitoConfig = new AmazonCognitoSyncConfig();
awsCognitoConfig.RegionEndpoint = RegionEndpoint.USEast1;
_cognitoCredentials = new CognitoAWSCredentials(CognitoDefaultValues.ID_POOL, RegionEndpoint.USEast1);
_cognitoSyncMgr = new DefaultCognitoSyncManager(_cognitoCredentials,awsCognitoConfig);
Sent from Windows Mail
From: phamt Sent: Thursday, March 5, 2015 3:06 PM To: 'awslabs/aws-sdk-xamarin' Cc: Tara Walker
The name of the assembly is still AWSSDK_XMOBILE.
The stacktrace just happens to resolve the source code to my local disk where the assembly was built from.
— Reply to this email directly or view it on GitHub.
What I should have additionally noted was for you to use the CognitoSyncClient, just ensure that you pass a CognitoSyncConfig with an RegionEndpoint or set an endpoint appropriately.
Sent from Windows Mail
From: Tara Walker Sent: Thursday, March 5, 2015 3:13 PM To: 'awslabs/aws-sdk-xamarin', awslabs/aws-sdk-xamarin
I should have looked at your code more closely. Your error was not that the code did not find a Regional Endpoint, you did not set a Regional Endpoint which is required for all AWS Services.
Example:
AmazonCognitoSyncConfig awsCognitoConfig;
awsCognitoConfig = new AmazonCognitoSyncConfig();
awsCognitoConfig.RegionEndpoint = RegionEndpoint.USEast1;
_cognitoCredentials = new CognitoAWSCredentials(CognitoDefaultValues.ID_POOL, RegionEndpoint.USEast1);
_cognitoSyncMgr = new DefaultCognitoSyncManager(_cognitoCredentials,awsCognitoConfig);
Sent from Windows Mail
From: phamt Sent: Thursday, March 5, 2015 3:06 PM To: 'awslabs/aws-sdk-xamarin' Cc: Tara Walker
The name of the assembly is still AWSSDK_XMOBILE.
The stacktrace just happens to resolve the source code to my local disk where the assembly was built from.
— Reply to this email directly or view it on GitHub.
Thanks very much, that resolved my issues.
The sample code available in the AWS Console for the .NET SDK seems to be out of date or doesn't line up with the AWS Xamarin SDK implementation. Can you provide any sample project or code?
Thanks!
@phamt what did you change to fix the issue?
I have a Xamarin iOS (unified api) test app that is trying to create some test data but I am able to to create an instance of CognitoAWSCredentials with a ArgumentNull Exception. on the "stream" parameter. I tried both using the latest Nuget packages as well as using the latest binaries with no luck.
Here's the sample code and stacktrace:
System.ArgumentNullException: Argument cannot be null. Parameter name: stream at System.IO.StreamReader.Initialize (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00199] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:255 at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen) [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:166 at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:152 at System.IO.StreamReader..ctor (System.IO.Stream stream) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamReader.cs:139 at Amazon.RegionEndpoint.LoadEndpointDefinitionsFromEmbeddedResource () [0x00000] in:0
at Amazon.RegionEndpoint.LoadEndpointDefinitions () [0x00000] in :0
at Amazon.RegionEndpoint.GetEndpointForService (System.String serviceName) [0x00000] in :0
at Amazon.Runtime.ClientConfig.set_RegionEndpoint (Amazon.RegionEndpoint value) [0x00000] in :0
at Amazon.CognitoIdentity.AmazonCognitoIdentityClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.RegionEndpoint region) [0x00000] in :0
at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String accountId, System.String identityPoolId, System.String unAuthRoleArn, System.String authRoleArn, Amazon.RegionEndpoint region) [0x00000] in :0