The value of IgnoredAssemblies is null when AppDomainAssemblyTypeScanner#UpdateAssemblies initializes, which causes problems when scanning certain assemblies (like Microsoft.Web.Mvc).
Another fix is to simply catch the type load exception (https://github.com/runesoerensen/Nancy/compare/fix-typeload-exception) when "GetExportedTypes" is loaded, but it seems like the above solution would allow for the (supposedly intended) configurability of what assemblies should be ignored.
Set IgnoredAssemblies when initializing AppDomainAssemblyTypeScanner
It appears to be missing indeed. Although I don't think it should be put in the static constructor of the appdomainassemblytypescanner. UpdateIgnoredAssemblies should be called when the defaultinternalconfig is created I think. I should probably have written a unit test for this when I wrote it :).
That might be a better idea although it wont solve the problem. Calling AppDomainAssemblyTypeScanner.UpdateIgnoredAssemblies will still cause the error , because it still (in turn) calls "UpdateAssemblies" before the IgnoredAssemblies are set.
How about removing the "LoadAssemblies" call from the AppDomainAssemblyTypeScanner constructor and put it somewhere else?
Right so I talked about this with @grumpydev and although he isn't really sure, he/we thinks the solution should be as follows. You were in the right direction :). The static constructor should be removed from the AppDomainAssemblyTypeScanner. This will defer the first loading of assemblies to the constructor of the BootstrapperBase. Giving the time to set the IgnoredAssemblies property on the AppDomainAssemblyTypeScanner to the correct value (with adjustments from the user). I'll do a pull-req with these changes tomorrow, and then @grumpydev can have a look at it and decide on the eventual solution.
My proposed solution is here: https://github.com/albertjan/Nancy/tree/fix-ignored-assemblies.
Will review for 0.13
I think this is now fixed