A reference is loaded only when you execute a method, which uses a type from the referenced .dll. So even if you reference the whole .NET framework, it will not be loaded automatically.
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
Console.WriteLine("=====Working with URI...=====");
WorkWithUri();
Console.WriteLine("=====Working with XML...=====");
WorkWithXml();
}
private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
Console.WriteLine(args.LoadedAssembly.FullName + " has been loaded.");
}
private static void WorkWithUri()
{
var uri = new Uri("c:\\");
}
private static void WorkWithXml()
{
XDocument xml = new XDocument();
}
}
And the output:
=====Working with URI...=====
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 has been loaded.
=====Working with XML...=====
System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 has been loaded.
System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 has been loaded.
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 has been loaded.
Press any key to continue . . .