AWS C#:抛出状态为ServerProtocolViolation的WebException

时间:2017-05-18 04:20:19

标签: c# .net amazon-web-services

即使我选择了正确的区域,我也会遇到异常。相同的代码适用于不同的机器,但不适用于我的机器。

Please find attached screenshot...

这是一个例外: -

  

类型' Amazon.Runtime.AmazonServiceException'的例外情况发生了   在AWSSDK.Core.dll中但未在用户代码中处理

     

其他信息:具有状态的WebException   抛出了ServerProtocolViolation。

这是我的代码:

   public void GetMetricList()
    {

        //var client = createCloudWatchClient();
        var client = new AmazonCloudWatchClient("#############", "##################################", Amazon.RegionEndpoint.APSouth1);
        ///Get list of metrics 
        var getMetricsListRequest = new ListMetricsRequest()
        {
            Namespace= "AWS/EC2"                
        };

        var metricsListResponse = client.ListMetrics(getMetricsListRequest); 
     }

1 个答案:

答案 0 :(得分:0)

终于得到了解决方案。问题是我的机器中的代理设置。我所做的只是在我的web.config文件中添加了一行代码,它对我有用。     <system.net> <defaultProxy useDefaultCredentials="true" /> </system.net>