Room of a pleinolijf

Ask yourself this: how do I want to be remembered ?

Visual Studio 2003 Web Forms Designer Error with Page Inheritance

1 Comment

When you use VS2003, and you are working on a project that uses page inheritance (replacing the standard System.Web.UI.Page by a BasePage class of your own), you probably have seen the following error when double-clicking an aspx page: “The file could not be loaded into Web Forms Designer” and some other blablabla…

I know of some workarounds, and this guy Tobin Harris [ ] has summed them up all nicely on one page [ ].

They are not a guaranteed solution however, but in many cases one of the workarounds might help you. If not the case, I read some other workaround somewhere on some site that I can’t remember 🙂  Here we go ! [ ]

It states that the problem is when your custom BasePage class is declared abstract, and this way, the Forms Designer can’t instantiate any of the methods, and thus is unable to build a view of the web page.
The workaround consisted of writing extra code like this:

public class BasePage : System.Web.UI.Page
public abstract class BasePage : System.Web.UI.Page
public virtual void method1()
throw new NotImplementedException();
public abstract void method1()

If you’re developing, you’re in debug mode, and that’s the only time you’ll need the Forms Designer. if you need that crap at all, cause basically it does more bad then good, but it also triggers and fires the annoying error message when directly viewing the HTML code. When deployed, you’ll mostly use a release build, and that’s when your BasePage class will be declared abstract, like it should be.

TechnoratiTechnorati Tags: , , , , ,


Author: pleinolijf

father | volleyballer | software engineer

One thought on “Visual Studio 2003 Web Forms Designer Error with Page Inheritance

  1. I will have to try this out on monday when I go back into work thanks for putting it all in one easy to reach place Andrew.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s