All Products
Search
Document Center

.NET SDK

Last Updated: May 28, 2019

Download URL

The Machine Translation . NET SDK allows developers of the Windows platform to use Alibaba Cloud Machine Translation conveniently through the .NET platform. Currently, the SDK supports . NET Framework 3.5, 4.0, and 4.5. SDK files vary with different .NET Framework versions, but the interfaces and functions are the same.

The GitHub address of the SDK is as follows: Click Here to access GitHub.

You also need to download the Alibaba Cloud . NET SDK

Procedure

To quickly start using the Machine Translation . NET SDK, take the following steps:

Step 1. Create an Alibaba Cloud account

For more information about how to create an Alibaba Cloud account, see Sign up with Alibaba Cloud.

We recommend that you complete real-name authentication as soon as possible to better use Alibaba Cloud services. Otherwise, some services may be unavailable.

Step 2. Obtain an Alibaba Cloud Access Key

To use the Machine Translation. NET SDK, you must apply for an Alibaba Cloud Access Key.

Log on to Alibaba Cloud’s Access Key Management page. Select an Access Key (consisting of an Access Key ID and Access Key Secret) for the SDK. If you do not have an Access Key, create one and make sure the Access Key is enabled.

Step 3. Install the . NET development environment

Currently, the Machine Translation SDK supports . the .NET 3.5 and .NET 4.0/4.5 running environments. To support Machine Translation SDK development, we recommend that you install:

  • Microsoft. Net Framework 3.5/4.0/4.5 (the specific version depends on the target environment required by your program.)
  • Visual Studio 2010 and later versions
  • We recommend that you download the Alibaba Cloud . NET SDK

Step 4. Download and install the Machine Translation. NET SDK

Install the Log Service After the .NET development environment is installed, install the Machine Translation . NET SDK. Details:

1. Download

Download the .NET SDK at GitHub: here

2. Note

If you are using Visual Studio 2017 to open the project, unload the feature test project inside the project solution.It is advised to install SDK using NuGet. Do not perform compilation.Examples of NuGet installation command:

  • dotnet add package aliyun-net-sdk-ros —version 2.2.8
  • dotnet add package aliyun-net-sdk-alimt

Step 5. Start a . NET program

  1. using Aliyun.Acs.Core;
  2. using Aliyun.Acs.Core.Profile;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.alimt.Model.V20181012;
  5. class TestProgram
  6. {
  7. static void Main(string[] args)
  8. {
  9. IClientProfile profile = DefaultProfile.GetProfile(
  10. "cn-hangzhou",
  11. "<your-access-key-id>",
  12. "<your-access-key-secret>");
  13. DefaultAcsClient client = new DefaultAcsClient(profile);
  14. try
  15. {
  16. TranslateGeneralRequest request = new TranslateGeneralRequest();
  17. request.Method = "POST";
  18. request.FormatType = "text";
  19. request.SourceLanguage = "zh";
  20. request.SourceText = "你好";
  21. request.TargetLanguage = "en";
  22. TranslateGeneralResponse response = client.GetAcsResponse(request);
  23. System.Console.WriteLine(response.Data);
  24. }
  25. catch (ServerException ex)
  26. {
  27. System.Console.WriteLine(ex.ToString());
  28. }
  29. catch (ClientException ex)
  30. {
  31. System.Console.WriteLine(ex.ToString());
  32. }
  33. }
  34. }