ImageResizer抛出"对象引用未设置为对象的实例。"更新后

时间:2017-01-16 12:47:03

标签: c# azure imageresizer

我正在尝试使用NuGet的最新ImageResizer软件包更新我们的解决方案。

更新后,我得到了以下null异常。所以我尝试恢复我的解决方案并再次更新包。同样的问题。 我也尝试使用ImageResizer中内置的诊断页面,但这也有同样的问题。 在NuGet更新期间没有出现任何问题。

堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.]
   ImageResizer.Configuration.PluginConfig.ParseName(String typeName) +8
   ImageResizer.Configuration.PluginConfig.FindPluginType(String searchNameString) +99
   ImageResizer.Configuration.PluginConfig.add_plugin_by_name(String name, NameValueCollection args) +16
   ImageResizer.Configuration.PluginConfig.loadPluginsInternal() +214
   ImageResizer.Configuration.PluginConfig.LoadPlugins() +93
   ImageResizer.Configuration.Config..ctor(ResizerSection config) +393
   ImageResizer.Configuration.Config.get_Current() +109
   ImageResizer.InterceptModule.System.Web.IHttpModule.Init(HttpApplication context) +276
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +536
   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

web.config中的Resizer设置:

  <resizer>
    <plugins>  
      <add name="AzureReader2" prefix="~/cloud/" connectionString="DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX" endpoint="https://XXX.windows.net/" />
      <add logging="true" />
      <add name="DiskCache" />
    </plugins>
    <clientcache minutes="60" />
    <diskcache enabled="true" dir="~/App_Data/DiskCache" AutoClean="true" hashModifiedDate="true" subfolders="32" cacheAccessTimeout="15000" asyncWrites="false" asyncBufferSize="10485760" />
    <cleanupStrategy startupDelay="00:05" minDelay="00:00:20" maxDelay="00:05" optimalWorkSegmentLength="00:00:04" targetItemsPerFolder="400" maximumItemsPerFolder="1000" avoidRemovalIfCreatedWithin="24:00" avoidRemovalIfUsedWithin="4.00:00" prohibitRemovalIfUsedWithin="00:05" prohibitRemovalIfCreatedWithin="00:10" />
  </resizer>

1 个答案:

答案 0 :(得分:0)

您可以在错误消息中看到错误发生在PluginConfig.ParseName(String typeName) - 因为这是一个空引用错误,这强烈暗示该名称为空。

查看配置的插件部分,显然您没有为logging插件指定名称:

<add logging="true" />

documentation表示这是正确的语法:

<add name="Logging" />