Fixing the “circular file references are not allowed” Error in ASP.net

Posted on December 3, 2009 at 11:41

If you get the “circular file references are not allowed” error in an ASP.net Website Project and you do not have any controls that have any obvious circular references, what does the error mean and how do you fix it?

See this blog post from Siderite Zackwehdex as well as this MSDN forum post: by default, in a Website Project, ASP.net compiles one dll per folder in an ASP.net project. So if you have the following setup:

/folder1/Control1.ascx > References Control2
/folder2/Control2.ascx > References Control3
/folder1/Control3.ascx

This means that the folder1 dll will reference the folder2 dll which will again reference the folder1 dll, causing a “circular file reference”.

Ways to fix it:

  1. Rearrange the layout of your controls (or masterpages) to remove the circular references (normally this will mean moving one control to another folder – in the example above, move control2 to folder1). This is the preferred solution.
  2. Use batch=”false” in the compilation tag of the web.config file. This will cause a new dll to be created for each control/page in the site. This should fix the error but is really lousy for performance, so it should be avoided (especially on production sites).

(This has happened to me a couple of times already, so posting it here as a reminder to myself for the next time).

  1. 12 Responses to “Fixing the “circular file references are not allowed” Error in ASP.net”

  2. 1) Mahmoud Alam on Dec 16, 2009 | Reply

    Thanks :)
    really helped me …

  3. 2) jalpari on Dec 23, 2009 | Reply

    it helps me out !
    really thanx although i did not like wot u said in last

    (This has happened to me a couple of times already, so posting it here as a reminder to myself for the next time)

  4. 3) Aref on Jul 4, 2010 | Reply

    Thank u…

  5. 4) chris on Sep 13, 2010 | Reply

    you could also put control3.ascx in /folder1/uc3/ this way it’s still organized into a logical grouping, as long as it’s not in the same folder with control1.ascx

  6. 5) Mike on Feb 14, 2011 | Reply

    This helped me snuff out a master page issue this morning. Thanks!

  7. 6) Hallgeir on Feb 22, 2011 | Reply

    I got this problem when I had hierarchy of usercontrols included into an .aspx. The solution was to add the following line into the system.web section in web.config.

  8. 7) Hallgeir on Feb 22, 2011 | Reply

    It seams like the xml from my previous post was removed when submiting.
    But add this line inside system.web section (including tags)
    compilation batch=”false”

  9. 8) Jonathan on Nov 29, 2011 | Reply

    Thanks a lot

  10. 9) Travis on Dec 7, 2011 | Reply

    Another way this can happen, even if you have batch=”false”, is by not checking ‘Use fixed naming and single page assemblies’ on the Publish Website configuration page, if you are, in fact, publishing the website. The publishing activity does not respect the compilation settings in the web.config file.

  11. 10) Paul on Dec 31, 2011 | Reply

    And … Visual Studio (2008) can just get confused and give the message erroneously. In my case, the message was pointing to a Register tag in a Master Page referencing a particular control.

    After checking version control for recent changes to the control and MasterPage, came up empty.

    Finally, just deleted the Src attrib of the Register tag and then filled it in with exactly the same file reference that was there before.

    Problem solved.

  12. 11) Pree on Jan 18, 2012 | Reply

    I have tried all these…but my error still stays on my head.. :-(

    if there is any other suggestion Plz help…

  13. 12) Johnson Yang on Jan 19, 2012 | Reply

    Thank you very much, that issue was bothering me for a long time until i read your post.

Post a Comment