error CS0122: 'AmazonS3Client.DeleteObject(DeleteObjectRequest)' is inaccessible due to its protection level #2104
-
Describe the bugCan't compile C# code from the example: Expected Behaviordelete s3 object Current Behaviorerror CS0122: 'AmazonS3Client.DeleteObject(DeleteObjectRequest)' is inaccessible due to its protection level Reproduction Steps// Create a client // Create a DeleteObject request // Issue request Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version used3.7.7.17 Targeted .NET PlatformNET 6 Operating System and versionWindows 10 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hi @dburtsev, Good afternoon. The Thanks, |
Beta Was this translation helpful? Give feedback.
-
error CS0029: Cannot implicitly convert type 'System.Threading.Tasks.Task<Amazon.S3.Model.DeleteObjectResponse>' to 'Amazon.S3.Model.DeleteObjectResponse' |
Beta Was this translation helpful? Give feedback.
-
@dburtsev Asynchronous versions return
AmazonS3Client client = new AmazonS3Client();
Amazon.S3.Model.DeleteObjectResponse resp = await client.DeleteObjectAsync(bucketName,keyName); OR
AmazonS3Client client = new AmazonS3Client();
Amazon.S3.Model.DeleteObjectResponse resp = client.DeleteObjectAsync(bucketName,keyName).Result; For more details about async/await pattern, please check Microsoft's documentation at Asynchronous programming with async and await. |
Beta Was this translation helpful? Give feedback.
-
error CS4032: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task' |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @dburtsev,
Good afternoon.
The
DeleteObject
(synchronous) version is available for applications targeting .NET Framework (refer). For applications targeting NetStandard (.NET Core or .NET 6), only asynchronous version DeleteObjectAsync is available. This is true for any Amazon service client, not justAmazonS3Client
.Thanks,
Ashish