Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Set IgnoredAssemblies when initializing AppDomainAssemblyTypeScanner #629

Conversation

runesoerensen
Copy link

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.

@runesoerensen
Copy link
Author

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
Copy link
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
Copy link
Contributor

My proposed solution is here: https://github.com/albertjan/Nancy/tree/fix-ignored-assemblies.

@grumpydev
Copy link
Member

Will review for 0.13

@grumpydev
Copy link
Member

I think this is now fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants