我从 2012 年继承了以下 AWS .NET SDK 代码,但在 SDK 中找不到许多类型。我添加了 nuget 包 Amazon、AWSSDK.Core、Amazon.EC2、Amazon.SimpleDB 和 Amazon.S3。using Amazon.EC2;using Amazon.EC2.Model;using Amazon.SimpleDB;using Amazon.SimpleDB.Model;using Amazon.S3;using Amazon.S3.Model; public static string GetServiceOutput() { StringBuilder sb = new StringBuilder(1024); using (StringWriter sr = new StringWriter(sb)) { sr.WriteLine("==========================================="); sr.WriteLine("Welcome to the AWS .NET SDK!"); sr.WriteLine("==========================================="); // Print the number of Amazon EC2 instances. AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(); DescribeInstancesRequest ec2Request = new DescribeInstancesRequest(); try { DescribeInstancesResponse ec2Response = ec2.DescribeInstances(ec2Request); int numInstances = 0; numInstances = ec2Response.DescribeInstancesResult.Reservation.Count; sr.WriteLine("You have " + numInstances + " Amazon EC2 instance(s) running in the US-East (Northern Virginia) region."); } catch (AmazonEC2Exception ex) { if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure")) { sr.WriteLine("The account you are using is not signed up for Amazon EC2."); sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2"); } 它说这些类型不存在:AmazonEC2、AWSClientFactory、DescribeInstancesResult、ex.StatusCode、AmazonSimpleDB。ListDomainsResult、IsSetListDomainsResult、AmazonS3。我做了很多谷歌搜索,但文档很糟糕。我不知道这些类型是否不再存在或者我可以使用哪些其他 AWS nuget 包?请帮忙
1 回答
慕容森
TA贡献1853条经验 获得超18个赞
2012 年的代码将使用旧的单片 SDK,其中所有服务都在一个程序集/nuget 包上,而我们只有几十个服务。现在有 100 多种服务,SDK 是每个服务的单独包加上核心包AWSSDK.Core
。
对于您,您需要添加 NuGet 包 AWSSDK.EC2、AWSSDK.S3 和 AWSSDK.SimpleDB。
此外,AWSClientFactory 类不再存在,因为它在 SDK 的模块版本中不起作用。只需将所有对 AWSClientFactory 的调用替换为服务客户端构造函数,即new AmazonEC2()
- 1 回答
- 0 关注
- 163 浏览
添加回答
举报
0/150
提交
取消