title: c# : Type.GetType called from a dll on exe type string
body: <p>I've the following class in <em>XmlSer.dll</em></p>
  
  <pre><code>namespace xmlser
  {
          public class XmlSer
          {
                  public Type test(string s)
                  {
                      return Type.GetType(s);
                  }
  
          //...other code
  
          }
  }
  </code></pre>
  
  <p>and the following code in <em>MyApp.exe</em>, which links <em>XmlSer.dll</em> as a reference</p>
  
  <pre><code>namespace MyApp
  {
      public class TestClass
      {
          public int f1 = 1;
          public float f2 = 2.34f;
          public double f3 = 3.14;
          public string f4 = "ciao";
      }
  
      class MainClass
      {
  
          public static void Main(string[] args)
          {
              TestClass tc = new TestClass();
              XmlSer ser = new XmlSer();
              Console.WriteLine(ser.test("MyApp.TestClass")!=null);
          }
  }
  </code></pre>
  
  <p>Running MyApp.exe I get <em>false</em>, that means that <em>ser</em> instance of <em>XmlSer</em> is not able to get the type of <em>Testclass</em> (result is <em>null</em>).
  Putting <em>XmlSer</em> class directly in <em>MyApp.exe</em> code I correctly get the type of <em>TestClass</em>.</p>
  
  <p>Checking on the net i've found that the problem is related to the assemblies. That means, the assembly of .exe is not visible to the <em>XmlSer.test</em> method so it can't resolve the type of <em>TestClass</em>.</p>
  
  <p>How can I resolve the problem maintaing <em>XmlSer</em> in <em>XmlSer.dll</em> and <em>MyApp.MainClass</em> in <em>MyApp.exe</em> ?</p>
  
  <p>Thanks.</p>
  
  <p>Alessandro</p>