How CLR Searches for dlls

Could someone tell if this article is correct on how CLR searches for it's dlls?

If James Burger is reading this, please tell me in reference to question entitled : Reference DLLs in your .NET Application you answered differently. James you indicated the GAC was searched last.

See  Article  ----
Quick Fix Engineering
If a referenced assembly has a strong name the load process is as follows:

• Assembly configuration files (discussed later) are examined to see what version of a referenced assembly to load.

• The CLR checks if the assembly was loaded in a previous call. If so, it is used.

• If the assembly isn't loaded the GAC is queried for a match and if found that's what's loaded.

• If a configuration file has a codebase entry for the assembly the file specified by this entry is used.

• If none of the above exist, the CLR looks for the referenced assembly starting in the application folder.

• If still not found, the CLR asks the Windows Installer service if it has the assembly. If so, the assembly is installed and this is the assembly used. This is call install on demand.

• If the assembly still cannot be found, an error is raised
Lawrence AverySystem DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
I am there.

The problem with what you are asking is that it cannot be represented only with a series of steps. A flowchart would be needed because there are a few ifs in there.

No matter where you look for, the first item is always something like "configuration files are examined to see what version of a referenced assembly to load." This skew everything else in the search. If there is nothing in the assembly configuration file, its straight to the GAC. But if there is something in the configuration files that points to another version than the one was compiled into the manifest or that requests remoting (meaning that the dll needs to be loaded or to run from the network).

The search will also be different whether the assembly is signed or not, because an assembly that is not signed cannot be stored in the GAC or be used through remoting.

Not always 1. 2. 3. 4.

Read 3 different articles on the topic, and they will all have variations on the sequence.

Your best bet would thus to go to the official documentation at

Yes, it comes in contradiction with what I told in my old post. It looks in the GAC first.
So who's wrong? James Burger or Microsoft. Probably not James Burger. And if you want the best answer, I would bet on Microsoft, not on me.

But I assume my contradiction.

In my work, I have to deal with the real world of a programmer. By experience, I know that this question is not so important. What is important is not where the framework looks, but that it finds the right assembly. And this is controlled more by the configuration files more than anything.

The only times I had problems with locating assemblies (and it happened more than once), where when I ended up with the wrong version of a dll, or more precisely, with the "right" version not installed. And this is controlled in step 1, in the configuration files.

When you have a problem such as that one, it is usually because the required version of a dll is not installed in the GAC, so knowing if the GAC is searched first or last has no impact, unless a programmer is stupid enough to distribute 2 different versions of a dll with the same signature and version number. I have to admit that there are quite a few stupid programmers that do that, but I never use dlls written by such programmers, so I don't care.

Knowing what the configuration files and a CodeBase can do is more important than knowing if the GAC is search first or last. I have always works with that assumption, and it has served me well for more than a decade.

If you really want to stick to the real thing, not the practical one, then nothing is as good as

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.