Assemblies, load context

David Levine asks me how to tell which load context an assembly is in. To my best knowledge, this information is not exposed in managed way. In fact, you don't even know whether an assembly has a context or not (Remember assemblies returned from Assembly.LoadFile/Assembly.Load(byte[]) do not have a context). This information is not really necesssary for managed applications. All the assemblies returned from various load API have the same functionality available to you. The load context is used for dependency probing. The rule is well defined, and you can't change the rule after the appdomain is created, and the assembly is returned.

So if the load context is exposed in managed world, it will be purely informational.

But then again, you should already have a pretty good idea about what will be in which load context. Assembly.Load(name) is always in default load context. Assembly.LoadFrom(), and its dependencies will most likely be in loadfrom context. Assembly.LoadFile and Assembly.Load(byte[]) do not have any context.

I know this does not really answer your question. But please post in comments for more questions.