Different location of assemblies stoped the type casting
<p>I am writing a custom Control class in C# for my main project. </p>

<p>There're 2 projects, one for my Control and one for my main project. These 2 projects are in the same solution. I add a reference from my main project to my Control project. I notice that the first time after I drag my Control from the Tool Panel onto my main winform,  an assembly folder was generated at the <em>C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies</em>, and the folder name is something like "<em>jlebh-py01</em>".</p>

<p>The first build is always OK, but after I rebuild my Control class or whole solution, a new assembly folder will be generated at <em>C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies</em>, and then problem arises, my Control fails to behave well because Visual Studio says that the two types "originates from different location". The error message is as below:</p>

<blockquote>
  <p>[A]MyControl.TypeXXX cannot be cast to
  [B]MyControl.TypeXXX. Type A orginates
  from assemblyXXX at location
  'C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies\jlebh-py01\MyControl.dll'
  Type B originats from assemblyXXX at
  location
  'C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies\ue4i-z3j01\MyControl.dll'</p>
</blockquote>

<p>If I reference the Control DLL directly instead of through project reference, or never rebuild the Control project after use my Control in the main project, things seem to be OK.</p>

<p>Does anyone knows why?  <em>Is it the proper way to develop a control and a main project within the same solution?</em></p>

<p>Many thanks...</p>
