创建了一个示例控制台应用程序,我正在尝试使用此代码连接到Azure文件存储。
var connectionString = "DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net;";
var shareClient = new ShareClient(connectionString, "testfileshare");
shareClient.CreateIfNotExists();
股份名称">测试文件共享";存在于账户中,并且">CreateIfNotExists((";方法调用引发带有消息的AggregateException
"6次尝试后重试失败";带有InnerException消息";这个基础连接已关闭:在发送">
我使用的是Azure.Storage.Files.Shares,12.4.0版本。目标框架是.NET4.6.2。尝试将目标框架更新为.NET4.7.2,但得到相同的错误。
为什么我会出现此错误?
添加堆栈跟踪:
at Azure.Core.Pipeline.RetryPolicy.<ProcessAsync>d__11.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Core.Pipeline.RetryPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
at Azure.Core.Pipeline.HttpPipeline.Send(HttpMessage message, CancellationToken cancellationToken)
at Azure.Storage.Files.Shares.FileRestClient.Share.<CreateAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Storage.Files.Shares.ShareClient.<CreateInternal>d__31.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Storage.Files.Shares.ShareClient.<CreateIfNotExistsInternal>d__34.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Storage.Files.Shares.ShareClient.CreateIfNotExists(IDictionary`2 metadata, Nullable`1 quotaInGB, CancellationToken cancellationToken)
at FileStorageTest.Program.Main(String[] args) in C:TestsFileStorageTestFileStorageTestProgram.cs:line 24
我发现了这个问题。当我从nuget添加Azure.Storage.Files.Shares包引用时,我观察到在项目文件Azure.Core引用是从";net461";文件夹和其他人正在从";netstandard2.0";文件夹和我的应用程序目标框架是";Net4.6.2";
这导致了问题。当我手动将Azure.Core引用路径更改为"时;netstandard2.0";它运行良好。
<Reference Include="Azure.Core, Version=1.5.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<!--<HintPath>..packagesAzure.Core.1.5.0libnet461Azure.Core.dll</HintPath>-->
<HintPath>..packagesAzure.Core.1.5.0libnetstandard2.0Azure.Core.dll</HintPath>
</Reference>
我通过升级";Azure.Storage.Files.Shares";包裹我不知道是VS问题还是nuget问题。