jeudi 13 août 2015

RavenDB within ASP.NET MVC with Unity causes ResolutionFailedException

I have the following:

  • ASP.NET MVC 5
  • RavenDB.Client version="3.0.3690"
  • Unity version="3.5.1404.0"
  • Unity.Mvc latest

Periodically, especially after the ASP.NET application has been idle for some time, upon loading the page I get the following exception:

Exception information: 
    Exception type: ResolutionFailedException 
    Exception message: Resolution of the dependency failed, type = "MyCompany.Web.Controllers.MainController", name = "(none)".
Exception occurred while: Calling constructor XXXXXXXX.
Exception is: FileNotFoundException - Could not load file or assembly 'ICSharpCode.NRefactory.CSharp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=d4bfe873e7598c49' or one of its dependencies. The system cannot find the file specified.

Note that ICSharpCode.NRefactory.CSharp appears to be an embedded assembly inside RavenDB. I don't reference it anywhere in my code, and it's not in the bin folder. I never get this error in a console or WPF application, so it must be something with unloading AppDomains and/or recycling ASP.NET AppPools.

Perhaps the code in Unity.Mvc doesn't handle the unloading of embedded assemblies properly. Or perhaps something is missing from the section of my web.config.

Once I get the error, I hit the F5 (Refresh) button in the browser, and viola, the error goes away and the page loads as expected.

Any idea?

Thanks, -Alec.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire