Azure Diagnostics正在寻找StorageClient 1.7.0.0,但我';m使用StorageClient 1.7.1.0

Azure Diagnostics正在寻找StorageClient 1.7.0.0,但我';m使用StorageClient 1.7.1.0,azure,storage,diagnostics,Azure,Storage,Diagnostics,我正在使用Microsoft.WindowsAzure.StorageClient版本1.7.1.0,可从以下网址获得:。我的项目编译得很好,但运行时出现以下错误: Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToke

我正在使用Microsoft.WindowsAzure.StorageClient版本1.7.1.0,可从以下网址获得:。我的项目编译得很好,但运行时出现以下错误:

Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
内部例外情况如下:

Could not load file or assembly 'Microsoft.WindowsAzure.StorageClient, Version=1.7.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)":"Microsoft.WindowsAzure.StorageClient, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
在Microsoft.WindowsAzure.StorageClient的1.7.0.0版上,Microsoft.WindowsAzure.Diagnostics中似乎存在依赖项。但是,我使用的是1.7.1.0版,据我所知,我不能在同一个项目中同时使用1.7.0和1.7.1版。如果这确实是问题所在,有没有办法让Microsoft.WindowsAzure.Diagnostics依赖于1.7.1

谢谢,库尔特


更新


根据下面的建议,我添加了s启动任务,以使用gacutil加载1.7.0版(这很有用)。我有两个工作角色和两个网络角色。现在的问题是,在编译和运行时,VS2012将1.7.0复制到WebRoles各自的…\csx\Debug\roles[WebRoleName]\approot文件夹中,尽管项目中没有直接引用版本1.7.0。下面的编译输出显示了Azure尝试加载verison 1.7.1(现在找不到)时引入的错误:


为什么VS2012会为1.7.0版添加DLL,而1.7.1版在项目本身中引用,而1.7.0版仅作为内容包含,并在应用程序启动时加载到GAC中?

在这种情况下,您将在web.config/app.config中使用绑定重定向。但问题在于PublicKeyToken。“官方”程序集1.7.0.0具有以下公钥令牌:31bf3856ad364e35

现在,由于您自己正在构建1.7.1.0版本,因此最终将使用不同的PublicKeyToken,在这种情况下,绑定重定向无法工作

但GAC就是为此而构建的,它支持一个程序集的多个版本。我的建议如下:

  • 在包中包括1.7.0.0程序集,但将其作为内容(而不是参考)添加
  • 创建一个将程序集部署到GAC的启动任务(使用gacutil),因为该任务是您的角色
  • 继续使用1.7.1.0和正常装配参考
  • 您的应用程序的代码应使用1.7.1.0,诊断程序集应能够使用GAC的1.7.0.0版

  • 我还没有机会对此进行测试,因此我期待您的反馈。

    看来我可以将以下参考添加到我的web.config中以解决此问题:

      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient"
                              publicKeyToken="31bf3856ad364e35"
                              culture="neutral" />
            <bindingRedirect oldVersion="1.1.0.0"
                             newVersion="1.7.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient"
                              publicKeyToken="31bf3856ad364e35"
                              culture="neutral" />
            <publisherPolicy apply="no" />
          </dependentAssembly>
    
        </assemblyBinding>
      </runtime>
    
    
    

    这基本上允许将对dll v1.1的引用重新映射到1.7。

    在您的版本中是否有特殊要求?老实说,我现在可能会回到1.7.0官方版本。每当第三方尝试加载存储客户端(例如Diagnostics agent)时,您都会遇到此问题。我本来打算对表和队列使用共享访问密钥功能,但我认为1.7.0不支持此功能。我假设(并且真的希望)1.7.1中的这个功能将成为正式的1.8.OK-这看起来很有希望。我添加了启动任务,但有一点小麻烦-我必须更改程序集的1.7.0文件名,否则当我尝试添加1.7.1版本时,Visual Studio将引用1.7.0,而不管我尝试添加直接引用到哪个版本。无论如何,现在我遇到了一个问题,当我试图构建我的解决方案时,仅针对WorkerRoles,VS2012将版本1.7.0(不是1.7.1)放入csx/Debug/roles/WorkerRoleName/approot文件夹,尽管在我的项目中没有直接引用它。对于WebRoles,将复制正确的版本(1.7.1)。有什么想法吗?我可以强制我编译的1.7.1的PublicKeyToken为31bf3856ad364e35吗?我实际上试图通过使用ILDASM将1.7.0的相关部分剪切并粘贴到1.7.1中来更改PublicKeyToken,但后来意识到我无法访问Microsoft的私钥:-(这意味着我必须关闭结果1.7.1的强名称验证,然后导致GetObjectData方法出现安全问题…关于“重写成员时违反继承安全规则…”我还尝试重命名和重新编译Microsoft.WindowsAzure.StorageClient的1.7.1版,程序集名称为Microsoft.WindowsAzure.StorageClient2。顺便说一句,这不应该被标记为答案,因为它对我不起作用。我没有足够的信誉点数来否决它。
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient"
                              publicKeyToken="31bf3856ad364e35"
                              culture="neutral" />
            <bindingRedirect oldVersion="1.1.0.0"
                             newVersion="1.7.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient"
                              publicKeyToken="31bf3856ad364e35"
                              culture="neutral" />
            <publisherPolicy apply="no" />
          </dependentAssembly>
    
        </assemblyBinding>
      </runtime>