user74042
user74042

Reputation: 739

dll used by CLR at runtime

I've got a C# application which refers to a .NET DLL.
If this DLL is present both in my application's bin directory and GAC, then which one will be picked up by the CLR at runtime? If GAC has the latest version, would that version be used instead of the one present in bin?

And how do I force the CLR to always use the one in my bin instead of GAC?

According to MSDN:

The CLR checks the global assembly cache, codebases specified in configuration files, and then checks the application's directory and subdirectories.

So, does that mean it looks into GAC first?
Thanks.

Upvotes: 1

Views: 289

Answers (1)

Hans Passant
Hans Passant

Reputation: 941327

You force the CLR to not use a copy of an assembly in the GAC by not having it in the GAC. Simple to do by renaming the DLL or by changing its [AssemblyVersion] before referencing it in your project. Skipping this invokes nasty runtime exceptions, otherwise known as DLL Hell.

Upvotes: 1

Related Questions