Search code examples
c#asp.net-mvc-4imageresizer

ImageResizer library: plugins fail to load unless the project is rebuilt


I'm using the ImageResizer library (version 3.2.4) in a ASP.NET MVC 4 project, with the following plug-ins: Watermark, MvcRoutingShim, DiskCache and SimpleFilters.

Everything works fine when I launch the project in Visual Studio 2012 for the first time.

But after stopping and restarting the project for 2 or 3 times, the plugins fail to load, which is confirmed in the diagnostic page:

(...)
Plugins(ConfigurationError):    Failed to load plugin by name "Watermark"
 Verify the plugin DLL is located in /bin, and that the name is spelled correctly. 

Plugins(ConfigurationError):    Failed to load plugin by name "MvcRoutingShim"
  Verify the plugin DLL is located in /bin, and that the name is spelled correctly. 
(...) etc.

The DLLs files are present in the \bin folder.

I can fix the problem by executing the project's "Clean" action in Visual Studio, and then "Rebuild".

But why are the plugins failing to load after some time?


Solution

  • It's likely that VS is being lazy about building dependencies that aren't referenced in code.

    Try referencing the DLLs from code instead of just from Web.config, it may help.

    Drop the following code into Application_Start:

    new WatermarkPlugin().Install(Config.Current); 
    

    See if Watermark still shows up on the diagnostics page as missing.