Circular file references not allowed

后端 未结 15 1890
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 19:10

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/CMSManagedT         


        
相关标签:
15条回答
  • 2020-12-18 19:42

    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.

    0 讨论(0)
  • 2020-12-18 19:44

    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.

    0 讨论(0)
  • 2020-12-18 19:46

    In most cases this occurs after copying aspx pages. Make sure your Class stated as Inherits="MyPage" is not repeated on the entire site.

    0 讨论(0)
  • 2020-12-18 19:47

    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.

    0 讨论(0)
  • 2020-12-18 19:47

    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.

    0 讨论(0)
  • 2020-12-18 19:48

    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!

    0 讨论(0)
提交回复
热议问题