简体   繁体   English

在开发期间访问Azure存储时无法加载程序集“Microsoft.Data.OData”

[英]Could not load assembly 'Microsoft.Data.OData' when accessing Azure Storage during development

I have created a simple C# application at visual studio and I try to run that from my local machine. 我在visual studio上创建了一个简单的C#应用​​程序,我尝试从本地机器上运行它。 I have visual studio 2013. However, when I try to run the program, I get the exception: Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral 我有visual studio 2013.但是,当我尝试运行程序时,我得到异常:无法加载文件或程序集'Microsoft.Data.OData,Version = 5.6.0.0,Culture = neutral

I have also tried the solution mentioned here: Could not load file or assembly Microsoft.Data.OData Version=5.2.0.0 error in Azure Cloud Worker Role using Table Storage 我也尝试过这里提到的解决方案: 无法使用表存储加载Azure Cloud Worker角色中的文件或程序集Microsoft.Data.OData Version = 5.2.0.0错误

That is to add the following at my config file: 那就是在我的配置文件中添加以下内容:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

But it still didn't work. 但它仍然没有奏效。 I do not know if I should change anything at the versions of that text. 我不知道我是否应该改变该文本的版本。

The line that throws the exception is: 抛出异常的行是:

    CloudTableClient client = storageAccount.CreateCloudTableClient();

I have also downloaded the package: http://www.nuget.org/packages/Microsoft.Data.Services.Client/ as mentioned at Missing Microsoft.Data.Services.Client version 5.6 on Azure Websites . 我还下载了软件包: http//www.nuget.org/packages/Microsoft.Data.Services.Client/,Azure网站上的Missing Microsoft.Data.Services.Client 5.6版所述 However the installer informed me that I already have the version 5.6.1.0 of the file and nothing happens. 但是,安装程序通知我,我已经拥有该文件的5.6.1.0版本,但没有任何反应。

Microsoft.WindowsAzure.Storage.StorageException was unhandled   HResult=-2146233088   Message=Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)   Source=Microsoft.WindowsAzure.Storage   StackTrace:
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       at Microsoft.WindowsAzure.Storage.Table.TableOperation.Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
       at Microsoft.WindowsAzure.Storage.Table.CloudTable.Execute(TableOperation operation, TableRequestOptions requestOptions, OperationContext operationContext)
       at UserConsoleProject2.Program.connectionAzureStorage() in c:\Users\user\Documents\Visual Studio 2013\Projects\UserConsoleProject2\UserConsoleProject2\Program.cs:line 42
       at UserConsoleProject2.Program.Main(String[] args) in c:\Users\user\Documents\Visual Studio 2013\Projects\UserConsoleProject2\UserConsoleProject2\Program.cs:line 419   InnerException: System.IO.FileLoadException
       HResult=-2146234304
       Message=Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
       Source=Microsoft.WindowsAzure.Storage
       FileName=Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
       FusionLog==== Pre-bind state information === LOG: DisplayName = Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  (Fully-specified) LOG: Appbase = file:///C:/Users/user/Documents/Visual Studio 2013/Projects/UserConsoleProject2/UserConsoleProject2/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : Microsoft.WindowsAzure.Storage, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
=== LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\user\Documents\Visual Studio 2013\Projects\UserConsoleProject2\UserConsoleProject2\bin\Debug\UserConsoleProject2.exe.Config 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: Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting download of new URL file:///C:/Users/user/Documents/Visual Studio 2013/Projects/UserConsoleProject2/UserConsoleProject2/bin/Debug/Microsoft.Data.OData.DLL. WRN: Comparing the assembly name resulted in the mismatch: Build Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

       StackTrace:
            at Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(Uri uri, UriQueryBuilder builder, IBufferManager bufferManager, Nullable`1 timeout, TableOperation operation, Boolean useVersionHeader, OperationContext ctx, TablePayloadFormat payloadFormat, String accountName)
            at Microsoft.WindowsAzure.Storage.Table.TableOperation.<>c__DisplayClass18.<RetrieveImpl>b__15(Uri uri, UriQueryBuilder builder, Nullable`1 timeout, Boolean useVersionHeader, OperationContext ctx)
            at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ProcessStartOfRequest[T](ExecutionState`1 executionState, String startLogMessage)
            at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       InnerException:

How can I make my program run? 如何让我的程序运行?

I ran into the same problem. 我遇到了同样的问题。 I got it to work by making sure I had the following libary versions installed from NuGet: 我通过确保从NuGet安装了以下libary版本来实现它:

Microsoft.Windows.Azure.Configuration 2.0.0.0
Microsoft.Windows.Azure.Storage 4.1.0.0
Microsoft.Data.Edm 5.6.1.0
Microsoft.Data.OData 5.6.1.0
Microsoft.Data.Services.Client 5.6.1.0
System.Spatial 5.6.1.0

I then changed my app.config to contain the following: 然后我将app.config更改为包含以下内容:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Note that the referenced assemblies are version 5.6.1.0 while the app.config refers to 5.6.0.0. 请注意,引用的程序集是版本5.6.1.0,而app.config是指5.6.0.0。 I don't know why this works. 我不知道为什么会这样。

Seems the following part of code missing in your web.config 似乎web.config中缺少以下部分代码

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

我有一个.net core2.0 webjob这个问题,找不到答案(这里或博客等)(这不是它,这可能适用于预核,但它给了我线索)...但是,当我将我的Microsoft.Azure.webjobs和.Extentions升级到beta4 3.0.0时,它解决了这个问题 - 如果这可以节省2天以上的人,那太好了。

Sometimes Visual Studio forgets to copy binaries from dependency projects. 有时,Visual Studio会忘记从依赖项目中复制二进制文件。 So, manually delete bin and obj folders and rebuild target project. 因此,手动删除binobj文件夹并重建目标项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure批处理作业错误:无法加载文件或程序集&#39;Microsoft.Data.OData - Azure batch job error:Could not load file or assembly 'Microsoft.Data.OData WebAPI OData无法加载microsoft.data.odata版本= 5.6.0.0 - WebAPI OData could not load microsoft.data.odata version=5.6.0.0 无法加载文件或程序集&#39;Microsoft.Data.OData,Version = 5.6.4.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35&#39;或其依赖项之一 - Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies 无法加载文件或程序集“ Microsoft.WindowsAzure.Storage” Azure函数 - Could not load file or assembly 'Microsoft.WindowsAzure.Storage' Azure Functions 无法加载文件或程序集“ Microsoft.Azure.Storage.Emulator.Controller” - Could not load file or assembly 'Microsoft.Azure.Storage.Emulator.Controller' Microsoft.AspNet.WebApi.OData与Microsoft.Data.OData和Microsoft.AspNet.OData有什么区别? - What is the difference between Microsoft.AspNet.WebApi.OData and Microsoft.Data.OData and Microsoft.AspNet.OData? 我可以从构建中排除Microsoft.Data.OData语言资源吗? - Can I exclude Microsoft.Data.OData languages ressources from build? 无法加载文件或程序集&#39;Microsoft.Azure.AppConfiguration.AzconfigClient - Could not Load file or assembly 'Microsoft.Azure.AppConfiguration.AzconfigClient 无法加载文件或程序集“Microsoft.Azure.Management.ServiceBus.Fluent” - Could not load file or assembly 'Microsoft.Azure.Management.ServiceBus.Fluent' 无法加载文件或程序集&#39;Microsoft.Azure.Graphs&#39; - Could not load file or assembly 'Microsoft.Azure.Graphs'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM