DependencyContext.Default throws when Assembly.GetEntryAssembly returns null #1017

jbogard opened this Issue Jan 4, 2017 · 4 comments


None yet

6 participants

jbogard commented Jan 4, 2017

I have some code that depends on DependencyContext.Default (an extension to IServiceCollection that scans DependencyContext.Default for assemblies. MVC Core gets around this by assuming the IHostingEnvironment.ApplicationName is the entry point assembly name.

MVC Core tooling assumes that DependencyContext.Default can be null (but it can't).

Steps to reproduce

Create an AppDomain and do not set its entry assembly, for example in a unit test:

public void ShouldNotThrowForNullEntryAssembly()
    DependencyContext defaultContext = null;
    Action act = () => defaultContext = DependencyContext.Default;


Expected behavior

That it not throw, perhaps with a null object representation that can be Merged with other assemblies

Actual behavior

DependencyContextLoader.Load throws a NullReferenceException

Environment data

Windows 10 x64

@jbogard jbogard referenced this issue in fixie/fixie Jan 4, 2017

Assembly.GetEntryAssembly is null #158

@moozzyk moozzyk was assigned by gkhanna79 Jan 4, 2017
moozzyk commented Jan 6, 2017

@gkhanna79 - I don't think I am the right assignee for this bug

@moozzyk moozzyk assigned gkhanna79 and unassigned moozzyk Jan 9, 2017

@schellap @pakrym Do either of you own this in Core-Setup repo?


@eerhardt any idea who this should go to?


any idea who this should go to?

Probably someone from the CLI team (either me or @livarcocc). Or possibly @pakrym, if he wants to take it.

@gkhanna79 gkhanna79 assigned livarcocc and eerhardt and unassigned gkhanna79 Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment