All Products
Search
Document Center

ApsaraVideo Live:Using the .NET SDK

Last Updated:Jun 20, 2026

This guide shows how to use the .NET SDK for ApsaraVideo Live and provides sample code.

Prerequisites

.NET Framework 4.5 or later, or .NET Core 2.0 or later.

Procedure

  1. Install the SDK.

    1. Log on to .

    2. On the Install page. In the All languages list, select .NET. The Quick Start tab shows how to install the ApsaraVideo Live SDK.

      This SDK requires .NET Framework 4.5 or .NET Core 2.0 or later. Select the .NET CLI tab and run the command dotnet add package AlibabaCloud.SDK.Live20161101 --version 2.0.0 to install the SDK.

  2. Create a project and use the Credentials tool to manage access credentials. For more information, see Managing access credentials.

  3. Make an API request and handle the response or exception.

    // This file is auto-generated, don't edit it. Thanks.
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    using Tea;
    using Tea.Utils;
    namespace AlibabaCloud.SDK.Sample
    {
        public class Sample 
        {
            /// <term><b>Description:</b></term>
            /// <description>
            /// <para>Use credentials to initialize the client.</para>
            /// </description>
            /// 
            /// <returns>
            /// Client
            /// </returns>
            /// 
            /// <term><b>Exception:</b></term>
            /// Exception
            public static AlibabaCloud.SDK.Live20161101.Client CreateClient()
            {
                // For security, we recommend that you avoid hard-coding your access credentials in the code. For more information about credential configuration, see https://www.alibabacloud.com/help/document_detail/378671.html.
                Aliyun.Credentials.Client credential = new Aliyun.Credentials.Client();
                AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    Credential = credential,
                };
                // See https://api.aliyun.com/product/live for endpoints.
                config.Endpoint = "live.aliyuncs.com";
                return new AlibabaCloud.SDK.Live20161101.Client(config);
            }
            public static void Main(string[] args)
            {
                AlibabaCloud.SDK.Live20161101.Client client = CreateClient();
                AlibabaCloud.SDK.Live20161101.Models.DescribeLiveDomainMappingRequest describeLiveDomainMappingRequest = new AlibabaCloud.SDK.Live20161101.Models.DescribeLiveDomainMappingRequest
                {
                    RegionId = "<Your RegionId>",
                    DomainName = "<Your DomainName>",
                };
                AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
                try
                {
                    // Add code here to process the response from a successful API call.
                    client.DescribeLiveDomainMappingWithOptions(describeLiveDomainMappingRequest, runtime);
                }
                catch (TeaException error)
                {
                    // The following code is for demonstration purposes only. Handle exceptions with caution. Do not ignore exceptions in your project.
                    // Error message
                    Console.WriteLine(error.Message);
                    // Troubleshooting URL
                    Console.WriteLine(error.Data["Recommend"]);
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
                catch (Exception _error)
                {
                    TeaException error = new TeaException(new Dictionary<string, object>
                    {
                        { "message", _error.Message }
                    });
                    // The following code is for demonstration purposes only. Handle exceptions with caution. Do not ignore exceptions in your project.
                    // Error message
                    Console.WriteLine(error.Message);
                    // Troubleshooting URL
                    Console.WriteLine(error.Data["Recommend"]);
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
            }
        }
    }