Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法删除空的S3存储桶_C#_.net_Amazon Web Services_Amazon S3 - Fatal编程技术网

C# 无法删除空的S3存储桶

C# 无法删除空的S3存储桶,c#,.net,amazon-web-services,amazon-s3,C#,.net,Amazon Web Services,Amazon S3,我正在尝试使用以下代码删除全新的S3存储桶: public void DeleteBucket(string bucketName) { s3Client.DeleteBucket(new DeleteBucketRequest() {BucketName = bucketName, UseClientRegion = true}); } 该存储桶未启用版本控制,并且其中没有文件。我可以从web界面删除它,但是,我无法使用上述代码删除它 我收到一个AmazonS3Excepti

我正在尝试使用以下代码删除全新的S3存储桶:

public void DeleteBucket(string bucketName)
{
    s3Client.DeleteBucket(new DeleteBucketRequest() {BucketName = bucketName, UseClientRegion =     true});
}
该存储桶未启用版本控制,并且其中没有文件。我可以从web界面删除它,但是,我无法使用上述代码删除它

我收到一个AmazonS3Exception错误,错误消息为“不允许针对此资源使用指定的方法”

错误代码为“方法不允许”

跟踪如下:

在Amazon.Runtime.AmazonWebServiceClient.d_1a.MoveNext()中 在里面 d:\Jenkins\workspace\build sdkandtools\sdk\src\AWSSDK\u DotNet45\Amazon.Runtime\AmazonWebServiceClient.cs:line 453---exception所在的上一个位置的堆栈结束跟踪 被扔到 System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess(任务 任务)在 System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult()
在
Amazon.Runtime.AmazonWebServiceClient.d_u3
1.MoveNext() 在里面 d:\Jenkins\workspace\build sdkandtools\sdk\src\AWSSDK\u DotNet45\Amazon.Runtime\AmazonWebServiceClient.cs:line 274---exception所在的上一个位置的堆栈结束跟踪 被扔到 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()位于 中的Amazon.S3.AmazonS3Client.DeleteBucket(DeleteBucketRequest请求) d:\Jenkins\workspace\build-sdkandtools\sdk\src\AWSSDK\u DotNet45\Amazon.S3\AmazonS3Client.cs:line 375位于WPFBucketManager.Service.AwsService.DeleteBucket(字符串 bucketName)在c:\Users\Matt\Documents\Visual Studio中 2012\Projects\BucketManager\WPFBucketManager\Service\AwsService.cs:line 28时 WPFBucketManager.ViewModel.ApplicationViewModel.DeleteSelectedBucket() 在c:\Users\Matt\Documents\Visual Studio中 2012\Projects\BucketManager\WPFBucketManager\ViewModel\ApplicationViewModel.cs:line 32在 WPFBucketManager.ViewModel.ApplicationViewModel.b_uu0(对象 c:\Users\Matt\Documents\visualstudio中的参数 2012\Projects\BucketManager\WPFBucketManager\ViewModel\ApplicationViewModel.cs:line 43在WPFBucketManager.Infrastructure.RelayCommand.Execute(对象 参数),在c:\Users\Matt\Documents\Visual Studio中 2012\Projects\BucketManager\WPFBucketManager\Infrastructure\RelayCommand.cs:line 55在 MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource,Boolean userInitiated)位于 System.Windows.Controls.Primitives.ButtonBase.OnClick()位于 System.Windows.Controls.Button.OnClick()位于 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) 在System.Windows.UIElement.OnMouseLeftButtonUpThunk(对象 发送器,鼠标按钮(e)位于 System.Windows.Input.MouseButtonEventArgs.InvokeeEventHandler(委托 genericHandler,对象genericTarget)位于 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象 目标)在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标, RoutedEventArgs RoutedEventArgs)位于 System.Windows.EventRoute.InvokeHandlerSimp(对象源、, RoutedEventArgs参数,布尔值重新分级)位于 System.Windows.UIElement.ReRaiseEventAs(DependencyObject发送方, RoutedEventArgs,RoutedEvent newEvent)位于 System.Windows.UIElement.OnMouseUpThunk(对象发送器, 鼠标按钮(e)在 System.Windows.Input.MouseButtonEventArgs.InvokeeEventHandler(委托 genericHandler,对象genericTarget)位于 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象 目标)在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标, RoutedEventArgs RoutedEventArgs)位于 System.Windows.EventRoute.InvokeHandlerSimp(对象源、, RoutedEventArgs参数,布尔值重新分级)位于 System.Windows.UIElement.RaiseEventImpl(DependencyObject发送方, RoutedEventArgs args)位于 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs参数)位于 System.Windows.UIElement.RaiseEvent(RoutedEventArgs参数,布尔值 受信任)位于System.Windows.Input.InputManager.ProcessStaginArea() 位于System.Windows.Input.InputManager.ProcessInput(InputEventArgs 输入)在 System.Windows.Input.InputProviderSite.ReportInput(InputReport) 输入报告)在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode模式、Int32时间戳、RawMouseActions操作、Int32 x、, Int32 y,Int32车轮)在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd、WindowMessage消息、IntPtr wParam、IntPtr lParam、布尔值& 处理)在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg、IntPtr wParam、IntPtr lParam、Boolean和handled)位于 MS.Win32.hwndwapper.WndProc(IntPtr-hwnd、Int32-msg、IntPtr-wParam、, 在 位于的MS.Win32.HwndSubclass.DispatcherCallbackOperation(对象o) System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调,对象args,Int32 numArgs)位于 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象 源,委托方法,对象参数,Int32 numArgs,委托 捕手)在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority 优先级、TimeSpan超时、委托方法、对象参数、Int32 在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg、IntPtr wParam、IntPtr lParam)位于 MS.Win32.unsafentivemethods.DispatchMessage(MSG&MSG)位于 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame 帧)在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame框架)
在System.Windows.Threading.Dispatcher.Run()中
 public class AwsService
{
    private readonly IAmazonS3 s3Client;
    private const string AccessKey = "ACCESSKEYREMOVED";
    private const string SecretKey = "SECRETKEYREMOVED";

    public AwsService()
    {
        s3Client = AWSClientFactory.CreateAmazonS3Client(AccessKey, SecretKey, RegionEndpoint.APNortheast1);
    }

    public List<S3Bucket> GetAllBuckets()
    {
        return s3Client.ListBuckets().Buckets.ToList();
    }

    public void DeleteBucket(string bucketName)
    {
        s3Client.DeleteBucket(new DeleteBucketRequest() {BucketName = bucketName, UseClientRegion = true});
    }
}
        public void CreateBucket(string bucketName)
    {
        s3Client.PutBucket(new PutBucketRequest() {BucketName = bucketName, UseClientRegion = true});
    }