So I've been having an issue getting the example from AWS to work for C#. I copy the code below straight from their site and put it in my program, but when it calls client.ListQueues(request); it tells me that it's inaccessible due to it's protection level. I've spent time searching, but I can't figure out why this isn't work. Any help would be appreciated.
var client = new AmazonSQSClient();
// List all queues that start with "aws".
var request = new ListQueuesRequest
{
QueueNamePrefix = "aws"
};
var response = client.ListQueues(request);
var urls = response.QueueUrls;
if (urls.Any())
{
Console.WriteLine("Queue URLs:");
foreach (var url in urls)
{
Console.WriteLine(" " + url);
}
}
else
{
Console.WriteLine("No queues.");
}
As it can be found in docs for some platforms the method ListQueues
is not available. The docs says:
For .NET Core, PCL and Unity this operation is only available in asynchronous form. Please refer to ListQueuesAsync.
So you have to use the asynchronous method ListQueuesAsync
and make your calling method asnyc. Your code should look like:
public async Task<Result> SomeAction()
{
var client = new AmazonSQSClient();
// List all queues that start with "aws".
var request = new ListQueuesRequest
{
QueueNamePrefix = "aws"
};
var response = await client.ListQueuesAsync(request);
// rest of the code
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With