Imageresizer.AzureReader2 不适用于最新的 Azure SDK 2.1.0.3

本文关键字:SDK Azure AzureReader2 不适用 适用于 最新 Imageresizer | 更新日期: 2023-09-27 18:36:56

我有一个 ASP.NET 的MVC 5应用程序,我已经升级到最新的SDK 2.1.0.3,看起来ImageResizer已经爆炸了。有什么解决方法吗?以下是详细信息:

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.WindowsAzure.Storage, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = xxx
LOG: Initial PrivatePath = xxx
Calling assembly : ImageResizer.Plugins.AzureReader2, Version=3.4.0.763, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: x
LOG: Using host configuration file: x
LOG: Using machine configuration file from x
LOG: Post-policy reference: Microsoft.WindowsAzure.Storage, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/6038b9fb/8488b4a1/Microsoft.WindowsAzure.Storage.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/6038b9fb/8488b4a1/Microsoft.WindowsAzure.Storage/Microsoft.WindowsAzure.Storage.DLL.
LOG: Attempting download of new URL x
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=2.1.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)]
   ImageResizer.Plugins.AzureReader2.AzureVirtualPathProvider..ctor(String blobStorageConnection) +0
   ImageResizer.Plugins.AzureReader2.AzureReader2Plugin.Install(Config c) +379
   ImageResizer.Configuration.PluginConfig.add_plugin_by_name(String name, NameValueCollection args) +275
   ImageResizer.Configuration.PluginConfig.loadPluginsInternal() +402
   ImageResizer.Configuration.PluginConfig.LoadPlugins() +102
   ImageResizer.Configuration.Config..ctor(ResizerSection config) +546
   ImageResizer.Configuration.Config.get_Current() +115
   ImageResizer.InterceptModule.get_conf() +36
   ImageResizer.InterceptModule.System.Web.IHttpModule.Init(HttpApplication context) +250
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=2.1.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)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874840
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Imageresizer.AzureReader2 不适用于最新的 Azure SDK 2.1.0.3

如果您

尝试Add-BindingRedirect但无处可去(它没有为我添加正确的重定向),您需要将以下内容添加到您的Web.Config

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <!-- Other bindings here! -->
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-2.1.0.3" newVersion="2.1.0.3"/>
        </dependentAssembly>
    </assemblyBinding>

在 NuGet 包管理器控制台中,运行以下命令:

PM> Add-BindingRedirect

这应该使你能够使用用于上一版本的图像调整器的不同版本的 Azure SDK。如果您通过NuGet安装/升级Microsoft.WindowsAzure.Storage,则它应该(但可能不会)自动运行。

您似乎缺少部署中的文件。 您是否引用了Microsoft.WindowsAzure.Storage v2.1.0.0并将其设置为CopyLocal=true?