title: ASP.Net error: “The type ‘foo’ exists in both ”temp1.dll“ and ”temp2.dll" (pt 2)
body: <p>Solution:</p>
  
  <p>I had also moved ashx and asmx files at the same time as this. The Class attribute of the WebService/WebHandler directives were pointed at the wrong namespace. The moral of the story is to make sure you view the markup for <strong>all</strong> <code>as*x</code> files you change the namespace for by right-clicking on them and choosing "View Markup".</p>
  
  <hr>
  
  <p>I'm experiencing the same problem as in <a href="https://stackoverflow.com/questions/371426/asp-net-error-the-type-foo-exists-in-both-temp1-dll-and-temp2-dll">this question</a> and <a href="http://forums.asp.net/p/998851/1312617.aspx" rel="nofollow noreferrer">this link</a>, but none of the answers fixed my problem. (edit: Setting the web.config batch attribute works, but that's a coverup, not a solution)</p>
  
  <p>The problem I'm having is with a User Control that I moved from the root directory to a subdirectory within the same Web Application project.  It used to work fine before I moved it. When I moved it it started giving me the error message.</p>
  
  <p>It's saying that the class name exists in two dll files in Temporary ASP.NET Files. Sure enough, when I open Reflector, it's in two dlls.</p>
  
  <p>If I rename the class and ascx file, everything works fine. No usages of the original name exist within any of the files in my entire application. When I rename the file, I opened all of the dll files in Temporary ASP.NET Files with Reflector, and no references to the original class name exists.</p>
  
  <p>So where's this phantom reference coming from how can I fix this?</p>
  
  <p>Update: I literally grepped every file in my working directory for the solution and my temp directory for the old class name and deleted every file that contained it. I then renamed back to the original, broken name and I still get the error.</p>
  
  <blockquote>
    <p>Server Error in '/' Application.
    Compilation Error  Description: An
    error occurred during the compilation
    of a resource required to service this
    request. Please review the following
    specific error details and modify your
    source code appropriately. </p>
    
    <p>Compiler Error ssage: CS0433: The type
    'ASP.dashboard_badusercontrol_ascx'
    exists in both 'c:\Docunts and
    Settings\me\Local
    Settings\Temp\Temporary ASP.NET
    Files\root\3c2b7e1f\2e8a7620\App_Web_badusercontrol.ascx.a57ad085.iljdmp1p.dll'
    and 'c:\Docunts and Settings\me\Local
    Settings\Temp\Temporary ASP.NET
    Files\root\3c2b7e1f\2e8a7620\App_Web_bhdqaimy.dll'</p>
    
    <p>Source Error:</p>
    
    <p>Line 1098:         Line 1099:<br>
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    Line 1100:        private
    global::ASP.dashboard_badusercontrol_ascx
    @__BuildControlMyBadUserControl() {
    Line 1101:<br>
    global::ASP.dashboard_badusercontrol_ascx
    @__ctrl; Line 1102:              </p>
    
    <p>Source File: c:\Docunts and
    Settings\me\Local
    Settings\Temp\Temporary ASP.NET
    Files\root\3c2b7e1f\2e8a7620\App_Web_foo.aspx.a57ad085.1nw6dais.0.cs
    Line: 1100 </p>
  </blockquote>
  
  <hr>
  
  <p>Edit:
  Ok, so I did some more testing on what works and doesn't work.
  Let's say the original file name was "BadUserControl.ascx" in namespace "MyNamespace".  </p>
  
  <p>I moved the file to a directory called "NewDirectory" and changed the namespace to "MyNamespace.NewDirectory". There are no copies of "BadUserControl.ascx" anywhere else on my HDD. I double-checked my TFS history to ensure the ONLY difference is the addition of ".NewDirectory" to the namespace in the markup and code-behind files.</p>
  
  <p>Inside of this namespace are two other user controls named "OtherUserControl" and "AnotherUserControl".</p>
  
  <p>This situation fails:
  I have 2 Register directives:    </p>
  
  <pre><code>&lt;%@ Register src="BadUserControl.ascx" tagname="BadUserControl" tagprefix="uc1" %&gt; 
  &lt;%@ Register src="OtherUserControl.ascx" tagname="OtherUserControl" tagprefix="uc2" %&gt;
  </code></pre>
  
  <p>These situations work:</p>
  
  <ol>
  <li><p>I keep "BadUserControl.ascx" named as is.
  I have 1 Register directive on a page in the same namespace:</p>
  
  <pre><code>&lt;%@ Register src="BadUserControl.ascx" tagname="BadUserControl" tagprefix="uc1" %&gt;
  </code></pre></li>
  <li><p>I change "BadUserControl.ascx" to "GoodUserControl.ascx" 
  I have 2 Register directives:</p>
  
  <pre><code>&lt;%@ Register src="GoodUserControl.ascx" tagname="GoodUserControl" tagprefix="uc1" %&gt;
  &lt;%@ Register src="OtherUserControl.ascx" tagname="OtherUserControl" tagprefix="uc2" %&gt;
  </code></pre></li>
  <li><p>2 Register directives without BadUserControl.ascx at all:</p>
  
  <pre><code>&lt;%@ Register src="AnotherUserControl.ascx" tagname="AnotherUserControl" tagprefix="uc1" %&gt;
  &lt;%@ Register src="OtherUserControl.ascx" tagname="OtherUserControl" tagprefix="uc2" %&gt;
  </code></pre></li>
  </ol>