3

I have created an applicataion in c#, where I need to put some data on S3 bucket, and to Invoke AWS sagemaker APIs. Since the same Amazon.RegionEndPoint class exists in both the references, it is giving below error.

The type 'RegionEndpoint' exists in both 'AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604' and 'AWSSDK, Version=2.3.55.2

Basically I am trying to upload files on AWS S3, following code I have used.

AmazonS3Client s3Client = new AmazonS3Client(_AWS_ACCESS_KEY_ID, _AWS_SECRETE_ACCESS_KEY, Amazon.RegionEndpoint.USEast2);
 PutObjectRequest request = new PutObjectRequest
  {
    BucketName = _BucketName,
    Key = i_sDestFileName,
    FilePath = i_sSourceFilePath,
    ContentType = "text/plain"
  };
  s3Client.PutObject(request);

It is working fine on a single application, but when I integrated code with Sagemaker API invokation, the conflict occurs for Amazon.RegionEndpoint.USEast2.

Diboliya
  • 1,124
  • 3
  • 15
  • 38

3 Answers3

2

Don't use AWSSDK package along with AWSSDK.Core. Remove it using the package manager and add your service-specific packages, for example, AWSSDK.S3 or AWSSDK.EC2 .

AWSSDK.Core is a new one with .NET core support and with that you need to install service-specific packages, while the older AWSSDK is a single package for all services. Below is the description of the older AWSSDK package from nuget:

This is the previous version 2 generation of the AWS SDK for .NET. The new version 3 of the AWS SDK for .NET uses separate packages for each service. For example Amazon S3 is in the AWSSDK.S3 package, Amazon SQS is in AWSSDK.SQS and Amazon DynamnoDB is in AWSSDK.DynamoDBv2.

Once you remove the older one and use the specific packages, the conflict will be resolved. But, note that there may be other errors then, as the constructs have changed slightly but are obvious/simple to fix. On the positive side, you get the async versions. ;)

--

// Noticed a comment from @Gerry-coll, above, on the main question, also mentions this. Leaving a detailed answer for others who bump into this issue even now.

Sumant
  • 2,201
  • 1
  • 16
  • 13
0

It looks like you have two different versions of the AWS SDK installed, one much older than the other. I'd look to SO questions like Where does error CS0433 "Type 'X' already exists in both A.dll and B.dll " come from? for advice on resolving the conflict.

Leopd
  • 41,333
  • 31
  • 129
  • 167
0

Consider moving your region details to of config file and access it from there. https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-region-selection.html enter image description here

Prem2530
  • 181
  • 3