我正在使用 Microsoft.WindowsAzure.StorageClient 版本 1.7.1.0,网址为:https ://github.com/WindowsAzure/azure-sdk-for-net/tree/sdk_1.7.1 。我的项目编译得很好,但是当我运行它时,我收到以下错误:
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.Diagnostics 中的 Microsoft.WindowsAzure.StorageClient 版本 1.7.0.0 存在依赖关系。但是我使用的是 1.7.1.0 版本,据我所知,我不能在同一个项目中同时拥有 1.7.0 和 1.7.1。如果这确实是问题,任何想法如何使 Microsoft.WindowsAzure.Diagnostics 依赖于 1.7.1?
谢谢,库尔特
更新
根据下面的建议,我添加了启动任务以使用 gacutil 加载 1.7.0 版本(这很有用http://blogs.infosupport.com/adding-assemblies-to-the-gac-in-windows-azure/)。我有 2 个 WorkerRoles 和 2 个 WebRoles。我现在遇到的问题是,当我编译和运行时,VS2012 将 1.7.0 复制到 WebRoles 各自的 ...\csx\Debug\roles[WebRoleName]\approot 文件夹中,尽管没有直接引用 1.7 版。项目中为 0。以下编译输出显示了当 Azure 尝试加载版本 1.7.1(现在找不到)时引入的错误:
System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.StorageClient, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.WindowsAzure.StorageClient, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = BERTIES_MAIN\kurt_000
LOG: DisplayName = Microsoft.WindowsAzure.StorageClient, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///H:/Everything/Current_Work/Web_Apps/Azure/InSysCloud/InSysCloud/InSysCloud/csx/Debug/roles/InSysWatcher/approot
LOG: Initial PrivatePath = H:\Everything\Current_Work\Web_Apps\Azure\InSysCloud\InSysCloud\InSysCloud\csx\Debug\roles\InSysWatcher\approot
Calling assembly : InSysWatcher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: H:\Everything\Current_Work\Web_Apps\Azure\InSysCloud\InSysCloud\InSysCloud\csx\Debug\roles\InSysWatcher\approot\InSysWatcher.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///H:/Everything/Current_Work/Web_Apps/Azure/InSysCloud/InSysCloud/InSysCloud/csx/Debug/roles/InSysWatcher/approot/Microsoft.WindowsAzure.StorageClient.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
为什么 VS2012 会为 1.7.0 版本添加 DLL,而 1.7.1 在项目本身中被引用,而 1.7.0 版本仅作为内容包含,并在应用启动时加载到 GAC 中?