不允许循环文件引用

发布于 2024-07-16 19:55:34 字数 1196 浏览 14 评论 0原文

我在 VS2008 中构建解决方案时遇到问题。 通常,它在环境中编译良好。 有时,它会失败:

/xxx_WEB/secure/CMSManagedTargetPage.aspx(1): error ASPPARSE: Circular
file references are not allowed.

我重建并且工作正常。

然而,现在我正在设置 CruiseControl.NET 系统,并在将构建集成到 CC 之前使用 MSBuild 测试我签出的代码。 现在,每次我使用 MSBuild 时,我都会得到:

"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.

问题是,我看不到该引用在哪里。

  • 我已经在整个解决方案中搜索了引用,除了在页面或其代码隐藏中或在字符串中之外,找不到任何对页面本身(CMSManagedTargetPage)的引用,例如:

    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";

我的汇编参考也很好(据我所知)。 我的 Web 应用程序位于依赖项的“顶部”,没有任何内容引用它,因此错误页面不会导致循环引用。 当然,页面本身可能引用同一程序集/网站内的 UserControl 等内容,但如前所述,对 CMSManagedTargetPage 的搜索未产生任何结果,因此不会发生这种情况。

更改 web.config 中的批处理属性对 MSBuild 没有影响。

我觉得很奇怪,它“有时”在 VS 中失败,而在 MSBuild 中总是失败。 我错过了一些微妙之处吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

美人如玉 2024-07-23 19:55:34

转贴自:

http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/

如果您有以下设置:
/folder1/Control1.ascx > 参考文献 控制2
/folder2/Control2.ascx > 参考文献 Control3
/folder1/Control3.ascx
这意味着folder1 dll将引用folder2 dll,后者将再次引用folder1 dll,从而导致“循环文件引用”。


这今天帮助了我; 我在根目录中有一个母版页引用文件夹中的母版页,该文件夹引用根目录中的另一个页面。 随机排列哪些页面位于哪些文件夹中就像一个魅力。

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.

玩心态 2024-07-23 19:55:34

当我遇到同样的问题时,我遇到了你的帖子。 循环引用问题可能有一百万种解决方案,但我的解决方案是母版页的直接结果。

我不小心在嵌套文件夹之外使用嵌套母版页创建了一个页面。
示例:

Master1.Master
Page.aspx
(Folder1) 
Master2.Master

当 Page.aspx 引用 Master2.Master 作为其母版页时,它会正常构建,但当我“发布”时出错。

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".

高冷爸爸 2024-07-23 19:55:34

我也遇到了这个问题,通过选择“使用固定命名和单页程序集”,能够从 Visual Studio 中成功发布。 由于某种原因,这似乎避免了编译器认为存在循环引用。

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.

饮湿 2024-07-23 19:55:34

我遇到了类似的问题,并从@JBicford 的回答中得到了密切的线索。 我在网站根目录上使用 Default.aspx,在另一个文件夹中使用 Master.master。 不知道这是否会导致这种情况,尚未测试此解决方案。

但对于有兴趣解决发布问题的人来说,以下选项适用于 VS 2012,所有其他选项都会失败,因为对其他文件夹和页面的依赖性不正确。

在此处输入图像描述

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.

enter image description here

人海汹涌 2024-07-23 19:55:34

我发现当 Visual Studio 批量编译页面时出现此错误。 我可以通过在 web.config 中的编译元素上设置 batch="false" 来解决此问题。

更具体地说,我在有问题的页面的目录中添加了一个 web.config。 该 web.config 文件仅包含以下内容:

<?xml version="1.0"?>

<configuration>
  <system.web>
    <!-- Added to prevent error ASPPARSE: Circular file references are not allowed. -->
    <compilation batch="false" />
  </system.web>
</configuration>

这样,如果需要,Visual Studio/MSBuild 仍然可以批量编译其他不受影响的目录。

有关编译元素和批处理属性的更多信息,请参见 msdn

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.

豆芽 2024-07-23 19:55:34

对我来说,它也在母版页上注册 aspx 页面。

例如(在母版页中):

<%@ Register Assembly="MyPage" Namespace="MyPage" TagPrefix="MyPage" %>
...
<asp:ContentPlaceHolder id="MyPage" runat="server"></asp:ContentPlaceHolder>

然后在 aspx 页面中:

<%@ 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">

删除寄存器修复了它。

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.

独留℉清风醉 2024-07-23 19:55:34

此错误在 ASP.NET 4.0 中仍然存在。

我得到的错误是:

/DirA/PageA.aspx(3): error ASPPARSE: Circular file references are not allowed.
/DirA/PageA.aspx(71): error ASPPARSE: Unknown server tag 'Controls:ControlA'.

ControlA 与 PageA.aspx(3) 上引用的控件相同。 我发现我必须将 ControlA 移动到与 PageA 相同的目录中才能停止此错误。

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.

倾其所爱 2024-07-23 19:55:34

我遇到了这个问题,但没有一个建议对我有用,我的可能是一个独特的案例,但以防万一其他人遇到同样的问题:

我的似乎与循环引用无关 实际上是由于我的构建输出。 一无所获后,我在无法加载的控件上放置了一个断点,并收到一条通知,告诉我它不会被击中。

更改项目属性解决方案配置设置以针对任何 CPU 进行构建解决了该问题。

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.

只为一人 2024-07-23 19:55:34

对于那些像我一样一直在讨论这个问题的人。 我相信我可能有另一种解决方案,如果其他方法都失败了。 我们在 MVC 应用程序中遇到了这个问题,我们花了几周时间尝试各种建议,但没有成功。

我们发现我们正在运行迈克菲病毒扫描程序 V 8.0。 我们发现,当我们从 VirusScan 控制台禁用按访问扫描程序时,我们能够毫无问题地构建和调试。

唯一的问题是,当此设置被禁用时,它将每 15 分钟自动重新启用一次。

我觉得这值得分享..

谢谢,
Dean

编辑:仅当您对计算机具有本地管理员访问权限时,此功能才有效。 从安全角度来看,关闭 AV 扫描仪存在合理的担忧(这是理所当然的)。 事实上,如果您的工作环境由网络管理员控制,您甚至可能会受到他们的拒绝。 我确信还有另一种方法可以做到这一点,但目前这似乎对我们有用,但如果我找到另一种解决方法(即网络管理员友好),我将在这里分享。

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.

提赋 2024-07-23 19:55:34

如果我有一个包含在母版页内的用户控件 (ASCX),我就会遇到此行为。

通常我只是忽略该错误,因为它在第二次构建后就消失了。

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.

陌伤ぢ 2024-07-23 19:55:34

实际上,这篇文章解释了为什么会发生这种情况以及如何解决它:
http://www.gitshah.com /2011/04/how-to-fix-circular-file-references-are.html

如何修复 ASP.Net 中的“不允许循环文件引用”错误

在我的一个 .Net 项目中,我遇到了一个有趣的问题。 我浪费了几个小时来修复它。 因此,我决定分享我的发现,以便其他人不必浪费时间解决同样的问题。

问题

问题非常简单,应用程序无法构建。 我在使用 MSBuild 构建 ASP.Net Web 项目时遇到的错误是:
/someProject/Controls/A/ucA.ascx(2):错误 ASPPARSE:不允许循环文件引用。

当然,错误表明我的代码中存在某种循环引用。 我环顾四周,检查并重新检查,是否错误地创建了循环引用。 但是,如果存在任何循环引用,代码将无法编译。 代码编译得很好,但当我们运行 aspnet_compiler.exe 时却失败了。

ASP.Net 编译工具 (aspnet_compiler.exe) 使您能够编译 ASP.Net Web 应用程序,这有助于提高应用程序性能,因为最终用户在向应用程序发出第一个请求时不会遇到延迟。

我再次检查,但肯定没有与代码相关的循环依赖项,那么为什么 aspnet_compiler.exe 抱怨循环文件引用?

说明

谷歌搜索了一下,我发现默认情况下,在网站项目中,ASP.Net 为每个文件夹创建一个 DLL。 因此,如果您有以下设置:

用户控件 ucA.ascx 存在于目录“A”中。 ucA.ascx 引用另一个用户控件 ucB.ascx
用户控件 ucB.ascx 位于目录“B”中。 ucB.ascx 引用另一个用户控件 ucC.ascx
用户控件 ucC.ascx 位于目录“A”中。

文件夹A的DLL将引用文件夹B的DLL,文件夹B将再次引用文件夹A的DLL,从而导致“循环文件引用”。

这就是 aspnet_compiler.exe 失败并出现“循环文件引用”错误的原因。

修复

有两种方法可以解决此问题

重新排列用户控件(或母版页)以删除循环引用。 通常这意味着将用户控件移动到单独的目录中。 在我们的示例中,将 ucC.ascx 移动到新目录“C”(首选解决方案)。
在 web.config 文件的编译标签中使用batch=”false”。 这将导致为站点中的每个控件/页面创建一个新的 DLL。 这应该可以修复错误,但对于性能来说确实很糟糕,因此应该避免。

我将 ucC.ascx 移到了另一个目录中,是的,错误消失了!

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!

别闹i 2024-07-23 19:55:34

对我来说这些技巧不起作用

- 设置batch = true
-删除asp.net临时文件并重置IIS
-替换可疑的ascx文件

,问题是由于将最近添加的项目引用到我的解决方案并在最终构建后卸载它。并删除对此新添加的库的引用解决了问题

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

如果没有 2024-07-23 19:55:34

我在重大开发检修期间也遇到了同样的错误。 在我的特定情况下,这是因为我使用的是“JUNK”文件夹,我在其中拖放未使用或重命名的文件。 我的垃圾文件夹正在编译,我最近删除的文件导致了此问题。

我通过排除垃圾文件夹中的单个文件来解决此问题。

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.

┼── 2024-07-23 19:55:34

我继承的一些代码也有同样的问题。

我的问题是 app_data 文件夹中有一个文件,但其中有一个 MyControls 命名空间。 我最终将该文件移出了 app_data 文件夹并创建了一个新文件夹“我的控件”。

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".

GRAY°灰色天空 2024-07-23 19:55:34

在大多数情况下,这发生在复制 aspx 页面之后。
确保您的类声明为 Inherits="MyPage" 不会在整个网站上重复。

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

念三年u 2024-07-23 19:55:34

另一个问题是代码隐藏: MasterPageA : B => 页C:B=> PageC 使用 MasterPageA。 出现错误“不允许循环文件引用”。
Visual Studio 不会报告此类中的错误。 你必须手动检查。

One another issue is in code behind: MasterPageA : B => PageC : B => PageC use MasterPageA. It occurs the error "Circular file references are not allowed".
Visual Studio does't report the error in this classes. You have to check manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文