Migrating to version 3.5 of the AWS SDK for .NET - AWS SDK for .NET

Migrating to version 3.5 of the AWS SDK for .NET

Version 3.5 of the AWS SDK for .NET further standardizes the .NET experience by transitioning support for all non-Framework variations of the SDK to .NET Standard 2.0. Depending on your environment and code base, to take advantage of version 3.5 features, you might need to perform certain migration work.

This topic describes the changes in version 3.5 and possible work that you might need to do to migrate your environment or code from version 3.

What's changed for version 3.5

The following describes what has or hasn't changed in the AWS SDK for .NET version 3.5.

.NET Framework and .NET Core

Support for .NET Framework and .NET Core has not changed.

Xamarin

Xamarin projects (new and existing) must target .NET Standard 2.0. See .NET Standard 2.0 Support in Xamarin.Forms and .NET implementation support.

Unity

Unity apps must target .NET Standard 2.0 or .NET 4.x profiles using Unity 2018.1 or later. For more information, see .NET profile support. In addition, if you're using IL2CPP to build, you must disable code stripping by adding a link.xml file, as described in Referencing the AWS SDK for .NET Standard 2.0 from Unity, Xamarin, or UWP. After you port your code to one of the recommended code bases, your Unity app can access all of the services offered by the SDK.

Because Unity supports .NET Standard 2.0, the AWSSDK.Core package of the SDK version 3.5 no longer has Unity-specific code, including some higher-level functionality. To provide a better transition, all of the legacy Unity code is available for reference in the aws/aws-sdk-unity-net GitHub repository. If you find missing functionality that impacts your use of AWS with Unity, you can file a feature request at https://github.com/aws/dotnet/issues.

Also see Special considerations for Unity support.

Universal Windows Platform (UWP)

Target your UWP application to version 16299 or later (Fall Creators update, version 1709, released October 2017).

Windows Phone and Silverlight

Version 3.5 of the AWS SDK for .NET does not support these platforms because Microsoft is no longer actively developing them. For more information, see the following:

Legacy portable class libraries (profile-based PCLs)

Consider retargeting your library to .NET Standard. For more information, see Comparison to Portable Class Libraries from Microsoft.

Amazon Cognito Sync Manager and Amazon Mobile Analytics Manager

High-level abstractions that ease the use of Amazon Cognito Sync and Amazon Mobile Analytics are removed from version 3.5 of the AWS SDK for .NET. AWS AppSync is the preferred replacement for Amazon Cognito Sync. Amazon Pinpoint is the preferred replacement for Amazon Mobile Analytics.

If your code is affected by the lack of higher-level library code for AWS AppSync and Amazon Pinpoint, you can record your interest in one or both of the following GitHub issues: https://github.com/aws/dotnet/issues/20 and https://github.com/aws/dotnet/issues/19. You can also obtain the libraries for Amazon Cognito Sync Manager and Amazon Mobile Analytics Manager from the following GitHub repositories: aws/amazon-cognito-sync-manager-net and aws/aws-mobile-analytics-manager-net.

Migrating synchronous code

Version 3.5 of the AWS SDK for .NET supports both .NET Framework and .NET Standard (through .NET Core versions like .NET core 3.1, .NET 5, and so on). Variations of the SDK that comply with .NET Standard provide only asynchronous methods, so if you want to take advantage of .NET Standard, you must change synchronous code so that it runs asynchronously.

The following code snippets show how you might change synchronous code into asynchronous code. The code in these snippets is used to display the number of Amazon S3 buckets.

The original code calls ListBuckets.

private static ListBucketsResponse MyListBuckets() { var s3Client = new AmazonS3Client(); var response = s3Client.ListBuckets(); return response; } // From the calling function ListBucketsResponse response = MyListBuckets(); Console.WriteLine($"Number of buckets: {response.Buckets.Count}");

To use version 3.5 of the SDK, call ListBucketsAsync instead.

private static async Task<ListBucketsResponse> MyListBuckets() { var s3Client = new AmazonS3Client(); var response = await s3Client.ListBucketsAsync(); return response; } // From an **asynchronous** calling function ListBucketsResponse response = await MyListBuckets(); Console.WriteLine($"Number of buckets: {response.Buckets.Count}"); // OR From a **synchronous** calling function Task<ListBucketsResponse> response = MyListBuckets(); Console.WriteLine($"Number of buckets: {response.Result.Buckets.Count}");