The blog of Tobin

Tobins nerd blog on .NET, Software, Tech and Nice Shiny Gadgets.

Tuesday, November 22, 2005

Aarrrggghhh: "The file could not be loaded into the Web Forms designer. Please correct the following error and then try loading it again"

Darn. Darn. Darn. This error has almost cost me a whole day!

If anyone gets this in VS.NET 2003 (I'm doing a VB.NET web project), then here's some solutions:

Workaround #1
Are you using page inheritance? If so, make sure none of your pages declare AND initialise attributes on the same line. So DO NOT do this:

private _securityGateway as Gateway = GatewayFactory.Create()

Instead do this:

private _securityGateway as Gateway

public sub Page_Load(...)
_securityGateway = GatewayFactory.Create()
end sub

This fixed my problems, but I'd already spent all day trying other things :-( Those were...

Workaround #2
Try removing (not deleting) the file from your Visual Studio Solution, and then re-add it back in.

Workaround #3
Delete all files from your Visual Studio web cache. E.g:

C:\Documents and Settings\Tobin Harris\VSWebCache\TOBINSLAPTOP\SomeProject

Workaround #4
Close Visual Studio and then delete as many files as possible from your temp folder. Eg:

C:\Documents and Settings\Tobin Harris\Local Settings\Temp

Anyway, hope that saves someone a day or hair pulling! Can't believe I got so stuck on this, I've never encountered such problems with C# web solutions. Ho hum...