CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

November 2005 - Posts

  • 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

  • Our Upgrade from ASP.NET 1.1 to ASP.NET 2.0

    Friday morning, I began the process of upgrading our public web site solution from ASP.NET 1.1 to 2.0.   Our public web solution contains over 20 projects and a fair amount of code.  After one day of work, it’s Monday morning and I’m basically done… 

    I did run into one snag, and it had to do with accessing our WSE 2.0 Web Services from .NET 2.0.   After the conversion, all of my WSE 2.0 code was deleted.  I did some research and mistakenly cam to the conclusion that I had to run WSE 3.0 with ASP.NET 2.0, which would mean converting all  my services to 3.0 as well.   I wasn’t looking forward to the amount of work this would entail, not to mention the logistical problem of updating many production apps that had this WSE 2.0 service dependencies.   Thankfully, Friday night I spoke with a friend who told me that WSE 2.0 works fine with .NET 2.0 and all I needed was SP3.  

    What actually had happened was that the conversion process deleted all of my WSE methods (dunno why) from my auto generated web service proxies.  If you’ve used WSE, you know that you get a [WebMethodName]Wse version of each web method, and that’s the proxy that you use when you need WSE support.  Well, the converter deleted these proxies, and I couldn’t get them back without reverting the code.  Finally what I did to fix this was to let the conversion run, and then get the previous version of the proxies from source control.  This allowed me to build and after some testing the WSE 2.0 stuff seems to be working fine.   So, this turned out to be more of a conversion issue than an actual technical one, thank goodness.   

    The VS team did a great job with the converter, and provided the following links that you should read before getting started:

    Upgrade from ASP.NET 1.x: Step-By-Step Guide to Converting Web Projects from Visual Studio .NET 2002/2003 to Visual Studio 2005

    If the application you are converting is of reasonable size and has several Web projects and additional projects, such as class libraries, in a single Visual Studio solution, it is possible to encounter issues during migration. Be prepared to spend the better part of a day completing the entire process.

    ASP.NET Developer Center: Upgrade from ASP.NET 1.x: Common ASP.NET 2.0 Conversion Issues and Solutions

    Common ASP.NET 2.0 Conversion Issues and Solutions

    So, I’m done with the conversion, and by that I mean I get a clean build and can launch and run the site.  I am by no means done, and ready to go into production.  I’d guess that I’m about two weeks away from that.  Now comes the hard part of finding out what actually broke, and the tedious task of testing everything, and then figuring out what all this App_Code/Migrated stuff is all about.

    -Brendan 

  • A Simple Alphabet Selection Control

    Recently, I decided that our user administration pages here at work for our public website was due for an overhaul.   The old version had become very painful to work with indeed, since depended on a categorized tree view of all of our registered companies and users on our public web site, it looked sorta like this:

    Our membership is in the thousands now, and the tree view paradigm has completely become unusable with this amount of data. In fact the HTML page size alone for this page was nearly a megabyte!  Ack!   I think there’s some UI rule here about tree views and expected data size, but I had to find a better way.   After some experimentation, the new design allows the admin to group the company list by alphabet.  The new design looks like this, and works much better. Total page size is under 150K now.  Not great, I know, but a vast improvement.  And for the small user population that uses this, it'll do fine for a while ;) .

    Anyhow, the alphabet selection control I thought may be something that will see some re-use, so I’ve implemented it as a simple custom control that can be dragged onto a web form.  It supports one event, ItemSelected, and has one property SelectedItem.  The idea is very simple, and chances are this has been done over and over again by many, but I thought I’d share this snippet of code here:

    Good Luck!

    -Brendan

    using System;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

     

    namespace YourNamespace.Web.UI.WebControls

    {

     

        [DefaultEvent("ItemSelected")]

        public class AlphabetList : System.Web.UI.WebControls.WebControl

        {       

            public event System.EventHandler ItemSelected;

     

            protected override void OnInit(EventArgs e)

            {

                for(char i='A'; i < 'Z'; i++)

                {

                    LinkButton lb = new LinkButton();

                    string alphaChar = i.ToString();

                    lb.Text = alphaChar;

                    lb.CommandArgument = alphaChar;

                    lb.Click += new EventHandler(lb_Click);

                    lb.ID = alphaChar;

                    this.Controls.Add(lb);

                    this.Controls.Add(new LiteralControl("&nbsp;"));

                }

     

                LinkButton lbAll = new LinkButton();

                lbAll.Text = "ALL";

                lbAll.CommandArgument = "ALL";

                lbAll.Click += new EventHandler(lb_Click);

                lbAll.ID = "ALL";

                this.Controls.Add(lbAll);

     

                base.OnInit(e);

     

            }

     

            /// <summary>

            /// Gets the selected item.

            /// </summary>

            /// <value>The selected item.</value>

            public string SelectedItem

            {

                get

                {

                    return this.ViewState["selected"] as string;   

                }

            }

     

            /// <summary>

            /// Handles the Click event of the lb control.

            /// </summary>

            /// <param name="sender">The source of the event.</param>

            /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>

            private void lb_Click(object sender, EventArgs e)

            {

                if(this.SelectedItem != null)

                {

                    (this.FindControl(this.SelectedItem) as LinkButton).Enabled = true;

                }

     

                this.ViewState["selected"] = (sender as LinkButton).CommandArgument;

                (sender as LinkButton).Enabled = false;

     

                if(this.ItemSelected != null)

                    this.ItemSelected(this, new EventArgs());

            }

        }

    }

  • In Search of More Stupidity : Open Source?

    I just finished reading In Search of Stupidity: Over 20 Years of High-Tech Marketing Disasters, by Merrill R. (Rick) Chapman.  Steve has a review here if you missed it.  It’s a bit dated, but is a great retrospective of our industry over the past twenty years.  I’d say it’s required reading for anyone who hasn’t been in the industry for twenty years, like myself.  Since I started working around 1993, and missed the pre-windows days of CP/M  systems and VisiCalc, this book was a great history lesson for me.  But what really struck me was the common sense perspective he takes on product marketing and the bubble. His view of what happened to all of us in the past 10 years has never been explained so clearly. 

    The interesting thing is that he describes so many stupid high-tech marketing ideas that we were all caught up in, and today they appear so plainly stupid that it’s embarrassing.  Especially if you’re like me and bought every idea, hook, line and sinker.  Here’s some examples of stupid ideas of the past ten years that I was completely caught up in:

    ASPs and Networked Computers –  Well, of course this idea was stupid.  As he points out, no one wanted to rent their software, especially when it was doggedly slow, and it also turns out we need spell checkers so often it doesn’t make any sense to rent them. But the thing was, I thought it was a good idea!  I remember thinking what a cool thing it would be to have one of these units, running Word and Excel remotely, and how if I just needed a spell checker, I could just rent one.  What a totally stupid idea!

    The Internet Bubble – Yes we all have been reminded that companies have to make money, and that shipping 50lb bags of dog food all over the company to fulfill a $10 order is stupid, but again, I thought it didn’t matter!  I remember telling people, all that matters is branding and unique daily visits.  Get the traffic and the money will follow.  I also remember telling people that the DJIA could possibly go up to well over 25,000!  Geesh, how could I (we) have been more wrong!

    So I began to wonder, are we currently making the same stupid mistakes by jumping on the Open Source bandwagon?  Certainly there are successes, like RedHat, and even our own friends Telligent Systems, but is open source a good idea for everyone, especially smaller projects?  If you read the hype from Red Hat you’d think so:

    Open source is inevitable. It returns control to the customer. The code is open and you can see it, change it, learn from it. Bugs are more quickly found and fixed. And when customers don't like how one vendor is serving them, they can choose another without overhauling their infrastructure. That means: No more arbitrary pricing. No more technology lock-in. No more monopolies.

    I’m beginning to worry about this.  I’m having a hard time getting anyone to submit feedback for my soon to be Open Source WSMQ project. I’ve had close to 400 downloads of the thing, but if I can’t get anyone to tell if they even think it’s a good (or lousy) piece of software, how am I every going to get people to donate time or money to the project?  I’m still in the very early stages, and haven’t even released it yet, but the writing is on the wall.  

    Could it be that if you give people something for free, they will just take it and give you nothing in return?  And by nothing, I mean nothing. No free development, certainly no money, and not even a thank you.. Can we blame them?  Don’t we all do the same thing? 

    I’m left with this sinking feeling that in another 5 years, Merrill Chapman will write another book, called We Found Stupidity: But We Did It Again.  In it, he’ll chronicle all sorts of stuff that we’re talking about right now, like the fact that letting your employees blog company direction is probably stupid.  And I think that he may just point out to all of us that the idea of making money by giving something away, could perhaps be, well… stupid.

    -Brendan

More Posts

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

MVP
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.