All Products
Search
Document Center

Alibaba Cloud SDK:.NET SDK FAQ

Last Updated:Jun 04, 2026

Answers to common questions about Alibaba Cloud SDK for .NET, including AccessKey configuration, timeout errors, and credential issues.

Prerequisites

.NET Framework 4.5+ or .NET Core 2.0+ is installed.

Overview

AccessKey configuration errors

The following error indicates an incorrect AccessKey pair:

  • Alibaba Cloud SDK V2.0: Unhandled exception. Tea.TeaException: Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly.

  • Alibaba Cloud SDK V1.0: Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Access key ID cannot be null.')

Solutions:

  1. Verify that the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are set:

    Linux or macOS

    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
    echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET

    Windows

    echo %ALIBABA_CLOUD_ACCESS_KEY_ID%
    echo %ALIBABA_CLOUD_ACCESS_KEY_SECRET%

    If a valid AccessKey pair is returned, the environment variables are correct. Otherwise, reconfigure them. For more information, see Configure environment variables in Linux, macOS, and Windows.

  2. Check for AccessKey-related errors in the code.

    Invalid example:

     AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    AccessKeyId = Environment.GetEnvironmentVariable("yourAccessKeyID"),
                    AccessKeySecret = Environment.GetEnvironmentVariable("yourAccessKeySecret"),
                };

    Valid example:

     AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    AccessKeyId = Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"),
                    AccessKeySecret = Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"),
                };
    Note

    These calls read the AccessKey ID and Secret from the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.

    Important

    To prevent AccessKey leaks, do not write the AccessKey pair in plaintext directly in your code.

TimeoutException errors

API call timeouts can have multiple causes. Common causes and solutions follow.

Network connectivity issues

The API request cannot reach the server due to a failed or unstable network connection.

Solutions:

Use ping or curl to test connectivity to the service endpoint. For example, if an SMS API call times out, run ping dysmsapi.aliyuncs.com or curl -v https://dysmsapi.aliyuncs.com.

  • If the command times out or returns no response, check your local firewall or router for block policies.

  • If a response is returned, set an appropriate timeout period. For more information, see Configure a timeout period. Sample code:

    // Configure the timeout period for connection requests by using runtime parameters. The timeout period takes effect only for requests that use RuntimeOptions.
    RuntimeOptions runtimeOptions = new RuntimeOptions();
    runtimeOptions.ConnectTimeout = connectionTimeoutMillis;

Long processing time of the API request

The API request processing time exceeds the read timeout period.

Solution: Extend the read timeout period. For more information, see Configure a timeout period. Sample code:

// Configure the timeout period for read requests by using runtime parameters. The timeout period takes effect only for requests that use RuntimeOptions.
RuntimeOptions runtimeOptions = new RuntimeOptions();
runtimeOptions.ReadTimeout = readTimeoutMillis;

ArgumentNullException: Value cannot be null

The Aliyun.Credentials package is outdated. Upgrade to the latest version:

dotnet add package Aliyun.Credentials

Common C# exceptions

Error message

Cause

Solution

SocketException

Socket-level failure such as a connection timeout or close.

Run cURL to verify network connectivity. Confirm the destination host and port are correct.

HttpRequestException

HTTP-level failure such as an unreachable server or request timeout.

Check the network connection and confirm the server is running. Use a try-catch block to handle this exception.

ProtocolViolationException

Protocol-level failure such as an invalid HTTP request or response.

Verify that the request and response conform to protocol requirements.

TimeoutException

An operation timed out.

Increase the timeout period or optimize performance to ensure the operation completes within the limit.

DNS resolution failure

The domain name cannot be resolved or is invalid.

Verify the domain name and confirm the DNS server is reachable.

Technical support

For other Alibaba Cloud SDK issues: