Brendan Tompkins [MVP]

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues

I’ve been plagued by  “Circular file references are not allowed” errors on our converted ASP.NET 2.0 applications.  This can happen when one ASCX control references another which contains a reference back to the first, but can also happen when there’s no obvious circular reference, such as when an ASCX control references another in a different directory that also contains other controls that reference back to the first one, or something like that (can you tell that I find this new build process slightly confusing?)… Point is, how do you get rid of it?

The docs mention this:

The solution for first type of circular reference is to create an abstract base class in the App_Code folder with one of the references, then remove the Reference directive from the associated web form or user control file. This will break the circular reference.

The second type of circular reference is a by-product of the ASP.NET compiler "batching" assemblies together for performance reasons. By default it will take the web forms and user controls in a folder and compile them into an assembly.

There are several ways to solve this issue, but we recommend moving the referenced pages (e.g. Pages2.aspx.vb and Pages3.aspx.vb) to their own folder. By default, the ASP.NET compiler will create a separate assembly containing these pages and the circular reference will be removed between Assembly A and B.

The circular references in our project weren’t completely obvious, and I’ve got bigger fish to fry right now than moving a bunch of files to get around this batch compilation issue. Fortunately, I  found some good discussion here about how to deal with this.  .

One additional note on batch=false -- this tells the ASP.NET compiler to not batch assemblies, and create an assembly for each web form and user control. When it is set to true, then the compiler will batch assemblies (in a non-deterministic way, but usually one per folder) which may hide broken references, including circular references. We recommend during development you run with batch=false, but for deployment set batch=true. This flag is set web.config, e.g.

Basically, you can just turn off batching during development, then turn it back on for deployment. Not a perfect solution, I know but will work for the time being, until I can get around to refactoring, to the recommend solution.

Another problem I ran into was running ASP.NET 2.0 and 1.1 applications side by side.  It turns out that most of the time, you can simply run your ASP.NET 1.1 compiled apps using the ASP.NET 2.0 runtime, but I did have one project that didn’t seem to want to run under 2.0.   So, I used the ASP.NET configuration tab to set the offending app to run using ASP.NET 1.1.  When I did this, I’d get “Server Application Unavailable” when running the project.  A quick peek in the event log revealed the culprit:

It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.

Well, this message is a bit confusing.. By “Server” they really mean “Site” or “Virtual Directory” and by “Separate Process,” they really mean Application Pool.  Setting the 1.1 site to run in its own App Pool did the trick.

We spent half of today in production with ASP.NET 2.0!  Hooray!  I’ve still got the CSS switch ready to turn it off if things go haywire, but for now things look good!

-Brendan


Posted 11-18-2005 3:59 PM by Brendan Tompkins

[Advertisement]

Comments

scottgu@microsoft.com wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 11-18-2005 6:05 PM
Cool stuff -- I'm glad ASP.NET 2.0 is running in production and working now.

Good luck with it,

Scott
Brendan Tompkins wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 11-19-2005 4:02 PM
*blush* Thanks Scott! :)
Bryan Thrasher wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 03-20-2006 2:42 PM
THANKS.  This saved me a ton of time.
Brandon wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 04-18-2006 3:34 PM
Yeah, I discoverd that you can't have a control that is on a master page in the same folder as a page that uses that master page.
Even when the master page is in another folder.
Fayaz wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 04-23-2008 11:19 AM

Well Thank you very much.This solved my problem.

Andrew Watson wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 12-16-2008 6:18 PM

Brendan, thanks a lot for this info! While working on my current ASP.NET project, I had an ASCX that up to today was working great. The all of a sudden I was getting the "Circular reference" error and things wouldn't build.

I used the "batch=false" option in the web.config you mention here, and things started working! Thanks again!

Stefan Bornemann wrote re: Circular File References and Other ASP.NET 2.0 / VS 2005 Conversion Issues
on 01-07-2009 10:00 AM

I found another possiblity to create this error. Two different UserControls, used on the same page, that contained a ASP:Button declared with the same ID caused this error.

The older Button was declared like this:

<asp:Button ID="btn_sortieren" runat="server" meta:resourcekey="btn_sortierenResource1" />

The newer Button in the other UserControl was declared like this:  

<asp:Button ID="btn_sortieren" Text="Sortieren" runat="server" />

Both UserControls are located in the same folder, but they are not referencing any other UserControl and they do not contain any UserControl.

Maybe the Use of Local Resources causes the problem, I did not test that.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?