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

Nancy attempt to load assemblies not actually used by the application #3003

Open
WenningQiu opened this issue Feb 25, 2020 · 0 comments
Open

Comments

@WenningQiu
Copy link

In upgrading my applications from Nancy 0.22 to 2.0.0, i found that some applications cannot even start up because Nancy apparently attempts to use System.Reflection.Assembly.ReflectionOnlyLoad() to resolve all assembly references, including the assemblies that the application does not actually need to run. I am not sure if the use of System.Reflection.Assembly.ReflectionOnlyLoad() is new in Nancy 2.0.0 or earlier as the Nancy version we are currently on is way too old.

Maybe Nancy's reflection logic can be made more tolerant of unresolved assembly references?

Below is an example call stack.

EXCEPTION (LEVEL 1): System.IO.FileNotFoundException
EXCEPTION MESSAGE: Could not load file or assembly 'Elasticsearch.Net' or one of its dependencies. The system cannot find the file specified.
STACK TRACE:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
at Nancy.Helpers.ProxyNancyReferenceProber.HasReference(AssemblyName assemblyNameForProbing, AssemblyName referenceAssemblyName)
at Nancy.Helpers.ProxyNancyReferenceProber.HasReference(AssemblyName assemblyNameForProbing, AssemblyName referenceAssemblyName)
at Nancy.AppDomainAssemblyCatalog.LoadNancyReferencingAssemblies(IEnumerable1 loadedAssemblies) at Nancy.AppDomainAssemblyCatalog.GetAvailableAssemblies() at System.Lazy1.CreateValue()
at System.Lazy1.LazyInitValue() at Nancy.DefaultTypeCatalog.GetTypesAssignableTo(Type type) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Nancy.DefaultTypeCatalog.GetTypesAssignableTo(Type type, TypeResolveStrategy strategy) at Nancy.Bootstrapper.NancyInternalConfiguration.<>c.<get_Default>b__1_0(ITypeCatalog typeCatalog) at Nancy.Bootstrapper.NancyInternalConfiguration.<>c_DisplayClass188_0.<WithOverrides>b_0(ITypeCatalog catalog) at Nancy.Bootstrapper.NancyBootstrapperBase1.GetInitializedInternalConfiguration()
at Nancy.Bootstrapper.NancyBootstrapperBase1.Initialise() at Nancy.Owin.NancyMiddleware.UseNancy(NancyOptions options) at Owin.AppBuilderExtensions.UseNancy(IAppBuilder builder, NancyOptions options) at Owin.MapExtensions.Map(IAppBuilder app, PathString pathMatch, Action1 configuration)
at Owin.MapExtensions.Map(IAppBuilder app, String pathMatch, Action`1 configuration)

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

No branches or pull requests

1 participant