System.IO.FileNotFoundException:无法加载文件或程序集System.Buffers或其依赖项之一。系统找不到指定的文件

问题描述 投票:0回答:1

我有一个 .NET 4.8 类库,我在其中使用 Azure.Storage.Blobs nuget 将文件上传到 Azure。 与 Azure 的连接已成功建立,但是我在文件上传之前收到错误 -

blockBlobClient.Upload(uploadFileStream);

错误指出-

System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
   at System.Reflection.RuntimeMethodInfo.GetParameters()
   at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Exception.GetStackTrace(Boolean needFileInfo)
   at System.Exception.get_StackTrace()
   at System.IO.FileNotFoundException.ToString()
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at AzureMain.AzureWrapper.UploadFileToAzure(String connectionString, String containerName, String blobName, String uploadFilePath) in D:\Azure new\AzureMain\AzureWrapper.cs:line 102
   at AzureMain.AzureWrapper.AzureInitialize(String connectionString, String containerName) in D:\Azure new\AzureMain\AzureWrapper.cs:line 46

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\SysWOW64\dllhost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Windows/SysWOW64/
LOG: Initial PrivatePath = NULL
Calling assembly : Azure.Storage.Blobs, Version=12.17.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

我的 DLL 的名称是 AzureMain,它是从同一 .net 4.8 框架中名为 AzureWrapper 的另一个 DLL 调用的。

我尝试将绑定重定向添加到 app.config as-

<dependentAssembly>
   <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
   <bindingRedirect oldVersion="4.0.2.0" newVersion="4.0.3.0" />
</dependentAssembly>

然而这并没有奏效。另外,我检查了nuget System.Buffers,这个nuget没有公开发布版本4.0.2.0

c# azure azure-blob-storage .net-4.8 class-library
1个回答
0
投票

确保绑定重定向位于正在运行的应用程序的应用程序项目的

app.config
web.config
中。在您的情况下,这可能是
AzureWrapper
,或者可能是引用
AzureWrapper
的另一个项目。

© www.soinside.com 2019 - 2024. All rights reserved.