问题
I am having a problem in building my solution in VS2008. Normally, it compiles fine in the environment. Sometimes, it fails with:
/xxx_WEB/secure/CMSManagedTargetPage.aspx(1): error ASPPARSE: Circular
file references are not allowed.
I rebuild and it works fine.
Now, however, I am in the middle of setting up a CruiseControl.NET system and am testing my checked out code with MSBuild before I integrate the build into CC. Now, everytime I MSBuild, I get:
"Q:\cc\xxx\checked out from svn\xxx.sln" (default target) (1) ->
(xxx_WEB target) ->
/xxx_WEB/secure/CMSManagedTargetPage.aspx(1): error ASPPARSE: Circular
file references are not allowed.
Problem is, I can't see where this reference is.
I have searched for the reference across the entire solution and canf ind no references to the page itself (CMSManagedTargetPage) anywhere other than in the page or its codebehind, or within a string, eg:
C:\dev2008\xxx\IWW.xxx.ASPNET\AspxHttpHandler.cs(82): inputFile = context.Server.MapPath("~/secure/CMSManagedTargetPage.aspx"); C:\dev2008\xxx\IWW.xxx.ASPNET\AspxHttpHandler.cs(83): virtualPath = "~/secure/CMSManagedTargetPage.aspx";
My assembly references are also fine (as far as I know). My Web Application is at the "top" of the dependencies, and nothing references it and therefore the faulting page so cannot cause a circular reference. Of course, the page itself may reference something such as a UserControl within the same assembly/web site, but as mentioned earlier, a search on CMSManagedTargetPage yielded no results so this is not happening.
Changing the batch attribute in web.config had no effect on MSBuild.
I find it very odd that it "sometimes" fails in VS and always fails in MSBuild. Am I missing some subtlety?
回答1:
Reposted from:
http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/
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”.
This helped me out today; I had a master page in the root referencing a master page in a folder, which referenced a different page in the root. Shuffling which pages were in which folders worked like a charm.
回答2:
I also ran into this problem, was able to get a successful Publish from within Visual Studio by selectin the "Use fixed naming and single page assemblies." For some reason that seems to avoid the compilier thinking there is a circular reference.
回答3:
I ran into your post when I ran into the same problem. There are probably a million solutions to a Circular reference problem, but mine was a direct result of Master Pages.
I accidentally created a page using a nested masterpage, outside the nested folder. Example:
Master1.Master
Page.aspx
(Folder1)
Master2.Master
While Page.aspx was referencing Master2.Master as its masterpage, It would build normally, and error when I "Publish".
回答4:
I had similar issue, and got a close clue from @JBicford's answer. I was using Default.aspx on root of website using Master.master in another folder. Don't know if that can cause that, haven't tested this solution yet.
But for someone who is interested in getting publishing problem sort out, below option works for VS 2012, all other options fail because of incorrect dependencies on other folders and pages.
回答5:
I found that I was getting this error when Visual Studio batch compiled pages. I was able to fix this issue by setting batch="false" on the compilation element in the web.config.
To be more specific, I added a web.config in the directory that had pages with issues. That web.config file only has the following content:
<?xml version="1.0"?>
<configuration>
<system.web>
<!-- Added to prevent error ASPPARSE: Circular file references are not allowed. -->
<compilation batch="false" />
</system.web>
</configuration>
That way, Visual Studio/MSBuild can still batch compile the other non-affected directories, if it desires.
More information about the compilation element and batch attribute are available at msdn.
回答6:
For me it was registering the aspx page on the master page as well.
For example (in the master page):
<%@ Register Assembly="MyPage" Namespace="MyPage" TagPrefix="MyPage" %>
...
<asp:ContentPlaceHolder id="MyPage" runat="server"></asp:ContentPlaceHolder>
And then in the aspx page:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="MyPage.aspx.cs" Inherits="MyPage" Title="Untitled Page" %>
<asp:Content ID="SomeContent" ContentPlaceHolderID="MyPage" Runat="Server">
Removing the Register fixed it.
回答7:
For those of you who like me have been going round and round with this issue. I believe I may have another solution is all else fails. We had this issue with an MVC application and we spent several weeks attempting the various suggestions to no avail.
What we found out was that we are running McAfee Virus scanner V 8.0. we found that when we disable the On-Access Scanner From the VirusScan Console we were able to build and Debug without issue.
The only thing is that when this setting it disabled It will automatically re-enable itself every 15 mins.
I felt that this was worth sharing..
Thanks, Dean
Edit: This works only if you have local admin access to your machine. From a security standpoint there is valid concerns about turning AV scanners off (rightfully so). In fact if your on a work environment that is controlled by a net admin you may even get push back from them. I'm sure there is another way to do this but for now this seems to work for us but if I find another workaround (that is net admin friendly) I will share here.
回答8:
I expericence this behavior if I have a user control (ASCX) that is included inside a master page.
Usually I simply ignore the error since it is gone after the second build.
回答9:
This bug still exists in ASP.NET 4.0.
The error I got was:
/DirA/PageA.aspx(3): error ASPPARSE: Circular file references are not allowed.
/DirA/PageA.aspx(71): error ASPPARSE: Unknown server tag 'Controls:ControlA'.
ControlA was the same control as referenced on PageA.aspx(3). I found that I had to move ControlA into the same directory as PageA in order to make this error stop.
回答10:
I had this problem but none of the suggestions worked for me, mine may be a unique case, but just in case other people encounter the same problem:
Mine seemingly had nothing to do with Circular References
and was in fact due to my build output. After a while of getting nowhere I placed a breakpoint on the control that couldn't be loaded and got a notification telling me that it would not be hit.
Changing both the project properties and solution configuration settings to build for Any CPU
rectified the problem.
回答11:
for me these tricks did not work
-setting batch=true -deleting asp.net Temp files and IIS reset -replacing suspicious ascx files
and the problem was from referencing a recent added project to my solution and unloading it after final build .and removing reference to this newly added library solved the problem
回答12:
I had this same error during a major development overhaul. In my particular case this was because I was using a "JUNK" folder where I was dragging and dropping unused or renamed files. My junk folder was being compiled and a file I recently deleted was causing this problem.
I fixed this by excluding the individual file in my junk folder.
回答13:
Same issue on some code I inherited.
My issue was I had a file in the app_data Folder, but it had a namespace of MyControls in it. I ended up moving that file out of the app_data folder and created a new folder "my controls".
回答14:
In most cases this occurs after copying aspx pages.
Make sure your Class stated as Inherits="MyPage"
is not repeated on the entire site.
回答15:
Actually, this post explains why it happens and how to fix it: http://www.gitshah.com/2011/04/how-to-fix-circular-file-references-are.html
How to fix the “circular file references are not allowed” Error in ASP.Net
On one of my .Net projects, I came across an interesting issue. I wasted couple of hours fixing it. Hence, I decided to share my findings, so that others do not have to waste their time fixing the same issue.
The issue
The issue was pretty simple, the app would not build. The error that I was getting while building a ASP.Net web project using MSBuild was: /someProject/Controls/A/ucA.ascx(2): error ASPPARSE: Circular file references are not allowed.
Of course the error said there is some sort of circular reference in my code. I looked around to check and recheck, if I have created a circular reference by mistake. However, if there was any circular reference, the code would not compile. Code was compiling fine but it was failing when we ran aspnet_compiler.exe.
The ASP.Net Compilation tool (aspnet_compiler.exe) enables you to compile an ASP.Net Web application, this helps application performance because end users do not encounter a delay on the first request to the application.
I checked again, but certainly there was no code related circular dependency then why the aspnet_compiler.exe was complaining about the circular file references?
The Explanation
Googling a little, I found that, by default, in a Website Project, ASP.Net creates one DLL per folder. Hence, if you have the following setup:
User control ucA.ascx is present in the directory "A". ucA.ascx refers another user control ucB.ascx User control ucB.ascx is present in the directory "B". ucB.ascx refers another user control ucC.ascx User control ucC.ascx is present in the directory "A".
The folder A's DLL will reference the folder B's DLL, which will again reference the folder A's DLL, causing a "circular file reference".
This is the reason why the aspnet_compiler.exe fails with the "circular file reference" error.
The Fix
There are two ways this issue could be fixed
Rearrange the user controls (or MasterPages) to remove the circular references. Usually this means moving the user controls in separate directories. In our example, moving ucC.ascx to a new directory "C" (Preferred Solution). 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.
I moved the ucC.ascx in a different directory and yes the error went away!
回答16:
So it seems that MasterPages are causing more problems with ASP.NET 2.0. I'be had problems with them before, and now seems to be the same.
I created a new page, without MasterPage and it worked fine. The MasterPage is literally used for styling only. Shame.
来源:https://stackoverflow.com/questions/729153/circular-file-references-not-allowed