Tous les produits
Search
Centre de documentation

ApsaraVideo Live:Utilisation du SDK .NET

Dernière mise à jour :Aug 19, 2026

Ce guide explique comment utiliser le SDK .NET pour ApsaraVideo Live et fournit des exemples de code.

Prérequis

.NET Framework 4.5 ou version ultérieure, ou .NET Core 2.0 ou version ultérieure.

Procédure

  1. Installez le SDK.

    1. Connectez-vous au .

    2. Sur la page Install. Dans la liste All languages, sélectionnez .NET. L'onglet Quick Start indique la procédure d'installation du SDK ApsaraVideo Live.

      Ce SDK nécessite .NET Framework 4.5 ou .NET Core 2.0 (ou une version ultérieure). Sélectionnez l'onglet .NET CLI et exécutez la commande dotnet add package AlibabaCloud.SDK.Live20161101 --version 2.0.0 pour installer le SDK.

  2. Créez un projet et utilisez l'outil Credentials pour gérer les identifiants d'accès. Pour plus d'informations, consultez la rubrique Gestion des identifiants d'accès.

  3. Envoyez une requête API et traitez la réponse ou l'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.alibabacloud.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);
                }
            }
        }
    }