tags:

views:

352

answers:

1

If I link a module against mydll.dll, which is deployed using WinSxS, the PE header in my module will simply reference "mydll.dll". How does Windows determine at runtime, firstly that this dependency should be loaded via WinSxS, and secondly what assembly it's in?

+4  A: 

It does so via the "activation context". In my opinion, WinSxS does not make any sense until you learn about the activation context and how it is managed.

I've put a rather long blog post explaining the details at http://omnicognate.wordpress.com/2009/10/05/winsxs/.

To summarise the article, the activation context is a structure that WinSxS uses at runtime to resolve unversioned object names (eg. DLL names) to the full information about how to locate them. The purpose of "manifests" in WinSxS is to construct activation contexts. Without understanding how and when these activation contexts are constructed and how they are managed (they are held on a thread-local stack), it is not possible to reason through the steps involved in loading a DLL via WinSxS and it is therefore impossible to diagnose the majority of problems that can arise.

This article was posted in Q/A format due to suggestions on meta: http://meta.stackoverflow.com/questions/24608/what-is-the-etiquette-for-posting-an-article.
Michael Myers
Note: I suggest putting at least a little bit of the article into the answer, to establish its relevance.
Michael Myers