Can I configure a .NET application in a way (settings in Visual Studio) that it references a "local" assembly (not in GAC) instead of an assembly within the GAC, although both assemblies have the same name and the same version?
C# – How to prevent a .NET application from loading/referencing an assembly from the GAC
assembliescgacnet
Related Topic
- C# – How to enable assembly bind failure logging (Fusion) in .NET
- .net – ASP.NET Web Site or ASP.NET Web Application
- C# – Case insensitive ‘Contains(string)’
- C# – How to remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning
- C# – Try-catch speeding up the code
- Scala: list.flatten: no implicit argument matching parameter type (Any) = > Iterable[Any] was found
- C# – Could not find a part of the path … bin\roslyn\csc.exe
- .net – the difference between .NET Core and .NET Standard Class Library project types
Best Answer
If both assemblies are strong-named (signed), the CLR will always load from the GAC.
Here are the steps the runtime uses to resolve assembly references (from How the Runtime Locates Assemblies):
As stated later in that same article:
So if you can afford to remove signing from the local assembly, the application will use it instead of the one in the GAC.
For more detail than you could probably ever want about the runtime-binding mechanisms, see Suzanne Cook's blog.
This blog entry from Scott Hanselman also provides a great overview of the binding process.