Type.GetType, partial assembly names. Getting types of an assambly in the GAC.

This article demonstrates what you could do when loading a type of an assembly that resides in the GAC.

Consider this piece of code of a console application. (System.Drawing) is NOT referenced!

            //Find by partial Name.
            Type partial = Type.GetType("System.Drawing.Rectangle, System.Drawing"); 
            //Find type with Assambly identity
            Type byIdent = Type.GetType("System.Drawing.Rectangle, System.Drawing, version=2.0.0.0,publicKeyToken=b03f5f7f11d50a3a,culture=neutral");

            if (partial == null)
                Console.WriteLine("alter app.config to let this work");

            if (byIdent == null)
                Console.WriteLine("Not found in GAC!");

            Console.ReadKey();

There are 2 way’s to load a type with partial assambly name.
1) place the assambly in the executing directory, the file will be found. (Consider the installation implications!)
2) Alter your app.config to

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <qualifyAssembly partialName="System.Drawing" fullName="System.Drawing,version=2.0.0.0,publicKeyToken=b03f5f7f11d50a3a,culture=neutral"/>
    </assemblyBinding>
  </runtime>
</configuration>

Leave a Reply