Set IgnoredAssemblies when initializing AppDomainAssemblyTypeScanner #629

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@runesoerensen

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.

@albertjan

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 :).

@runesoerensen

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?

@albertjan
Contributor

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.

@albertjan
Contributor
@grumpydev
Member

Will review for 0.13

@grumpydev
Member

I think this is now fixed

@grumpydev grumpydev closed this Jan 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment