In my .NET Framework 4.7.2 ConsoleApp with AnyCPU, i am tracing different assemblies loaded in current appdomain with AppDomain.CurrentDomain.GetAssemblies()
public static void Main(string[] args)
{
Console.WriteLine(typeof(System.Data.CommandBehavior).Assembly.Location);
Console.WriteLine(typeof(System.Collections.ArrayList).Assembly.Location);
Console.WriteLine(typeof(HashSet<>).Assembly.Location);
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Console.WriteLine(assembly.Location);
}
Console.ReadKey();
}
and here is the result:
mscorlib.dll
loaded fromFramework
directory (this path C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll)System.Core.dll
loaded fromGAC_MSIL
Directory (this path C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll)System.Data.dll
loaded fromGAC_32
Directory (this path C:\windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll)
known that the CLR loads assemblies using :
1-GAC
2-Current directory
My questions are :
- what is the role of Framework/Framwork64 Folder in CLR loading assemblies process (i know it's where .net framework runtimes installed)
- Does this CLR loads only runtime assemblies from this folder ? if yes is there any order ?
- My application is targeting AnyCPU why it loads assemblies from GAC_32 instead of GAC_MSIL?