I was minding my own business, making user controls in a big project we've been working for the last year and I've stumbled upon the "circular file references are not allowed." error. It was annoying not only because I haven't met before and I was certain there was no circular reference, but also because sometimes it compiled the whole site without any errors, only to fail the next build with the same error.

Google saved me when I found this discussion: http://forums.asp.net/t/922622.aspx. It might be a little long to read and understand so here is the short version:

ASP.Net 2.0 compiles sites by creating a DLL for each folder. Therefore if you have references that are not circular in pages, controls or classes, they can be circular in these DLLs. You have two solutions:

Solution A is to use batch="false" in the compilation tag of the web.config file. This is not really a solution as it forces ASP.Net to compile a DLL for each page and control. It might work, but it slows compilation terribly and it is also not suitable for production builds, only for development.

Solution B is to move all referenced controls in a single directory. In my case there was a Controls directory and one of the controls was outside, referenced both in a control in Controls and in a page in the base directory. Moving my user control to the Controls folder solved the problem!

Bottom line: try to avoid referencing across folders.

Comments

Post a comment