CS0122:'AmazonGlacierClient.ListVaults()' 由于其保护级别而无法访问
CS0122: 'AmazonGlacierClient.ListVaults()' is inaccessible due to its protection level
我收到以下错误:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0122
Program.cs(42,34): error CS0122: 'AmazonGlacierClient.ListVaults()' is inaccessible due to its protection level [/app/myglacier.csproj]
当 运行 此代码时:
var response = this.client.ListVaults();
SDK 链接:
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Glacier/MGlacierListVaults.html
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Glacier/TGlacierClient.html
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/
我的问题:
为什么我在“虚拟 public”方法上会收到此错误?为什么我无法访问它?
完整代码:
using System;
using System.Collections.Generic;
using Amazon.Glacier;
using Amazon.Glacier.Model;
namespace myglacier
{
class Program
{
static void Main(string[] args)
{
Myglacier mg = new Myglacier();
mg.init();
var vl = mg.getVaults();
Console.WriteLine("Hello World!");
}
}
public class Myglacier
{
public AmazonGlacierClient client = null;
public void init()
{
AmazonGlacierClient client;
client = new AmazonGlacierClient("&&&&&&&&&", "++++++++++++", Amazon.RegionEndpoint.USEast1);
}
public List<DescribeVaultOutput> getVaults()
{
var response = this.client.ListVaults();
List<DescribeVaultOutput> vaultList = response.VaultList;
return vaultList;
}
}
}
适用于 .NET 的 AWS 开发工具包因目标开发工具包而异。例如,冰川有 3 different targets:
- _bcl35
- _bcl45
- _netstandard
.NET 3.5 目标没有 AmazonGlacierClient
,因此我们可以排除这种情况。您的目标是 .NET Framework >= 4.5 或 .NET Standard(可能是 .NET Core)的某些实现。
.NET 4.5+ 版本确实有一个 public GetVaults()
方法。
.NET Standard 版本只有一个内部 GetVaults()
, but you have a public ListVaultsAsync()
可以使用。
请记住,适用于 .NET 的 SDK 是开源的,如果文档在这种情况下看起来有误,您可以随时查看。
我收到以下错误: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0122
Program.cs(42,34): error CS0122: 'AmazonGlacierClient.ListVaults()' is inaccessible due to its protection level [/app/myglacier.csproj]
当 运行 此代码时:
var response = this.client.ListVaults();
SDK 链接:
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Glacier/MGlacierListVaults.html
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Glacier/TGlacierClient.html
- https://docs.aws.amazon.com/sdkfornet/v3/apidocs/
我的问题:
为什么我在“虚拟 public”方法上会收到此错误?为什么我无法访问它?
完整代码:
using System;
using System.Collections.Generic;
using Amazon.Glacier;
using Amazon.Glacier.Model;
namespace myglacier
{
class Program
{
static void Main(string[] args)
{
Myglacier mg = new Myglacier();
mg.init();
var vl = mg.getVaults();
Console.WriteLine("Hello World!");
}
}
public class Myglacier
{
public AmazonGlacierClient client = null;
public void init()
{
AmazonGlacierClient client;
client = new AmazonGlacierClient("&&&&&&&&&", "++++++++++++", Amazon.RegionEndpoint.USEast1);
}
public List<DescribeVaultOutput> getVaults()
{
var response = this.client.ListVaults();
List<DescribeVaultOutput> vaultList = response.VaultList;
return vaultList;
}
}
}
适用于 .NET 的 AWS 开发工具包因目标开发工具包而异。例如,冰川有 3 different targets:
- _bcl35
- _bcl45
- _netstandard
.NET 3.5 目标没有 AmazonGlacierClient
,因此我们可以排除这种情况。您的目标是 .NET Framework >= 4.5 或 .NET Standard(可能是 .NET Core)的某些实现。
.NET 4.5+ 版本确实有一个 public GetVaults()
方法。
.NET Standard 版本只有一个内部 GetVaults()
, but you have a public ListVaultsAsync()
可以使用。
请记住,适用于 .NET 的 SDK 是开源的,如果文档在这种情况下看起来有误,您可以随时查看。