由于保护级别 (C#),无法访问 Amazon SNS client.publish

Amazon SNS client.publish is inaccessible due to protection level (C#)

我以前从未使用过 SNS,我正在使用它来尝试学习如何通过 SNS 发送电子邮件。我在网上找到了这段代码,似乎可以满足我的需要。我已经在浏览器中设置了主题等等,并确认了主题和我打算使用的电子邮件之间的联系。这是代码:

using System;
using System.Linq;
using System.Threading.Tasks;

using Amazon;
using Amazon.SimpleNotificationService;
using Amazon.SimpleNotificationService.Model;

namespace Sns_test
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Topic ARNs must be in the correct format:
             *   arn:aws:sns:REGION:ACCOUNT_ID:NAME
             *
             *  where:
             *  REGION     is the region in which the topic is created, such as us-west-2
             *  ACCOUNT_ID is your (typically) 12-character account ID
             *  NAME       is the name of the topic
             */
            string topicArn = "arn:aws:sns:us-east-2:058418336484:MailTest";
            string message = "Hello at " + DateTime.Now.ToShortTimeString();

            var client = new AmazonSimpleNotificationServiceClient(region: Amazon.RegionEndpoint.USWest2);

            var request = new PublishRequest
            {
                Message = message,
                TopicArn = topicArn
            };


            try
            {
                var response = client.Publish(request);

                Console.WriteLine("Message sent to topic:");
                Console.WriteLine(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught exception publishing request:");
                Console.WriteLine(ex.Message);
            }
        }
    }
}

这里的问题是:

            try
            {
                var response = client.Publish(request);

                Console.WriteLine("Message sent to topic:");
                Console.WriteLine(message);
            }

client.Publish(request) 由于其保护级别而无法访问。通常当我的代码无法访问时,我可以解决这些问题,但是对于库中内置的方法我该怎么办?

这是错误信息:[错误信息][1]

任何帮助将不胜感激:)

编辑:我设法通过使用 client.PublishAsync 来解决问题,但我仍然很好奇为什么 client.Publish 无法访问。 [1]: https://i.stack.imgur.com/av3fO.png

查看文档

https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/SNS/MSNSPublishPublishRequest.html

Note:
For .NET Core this operation is only available in asynchronous form. Please refer to PublishAsync.