Hey all,
There seems to be some bugginess in VS 2008 sp1 that we
were struggling with a little bit today.
At this last point, after a 5 minute chain of subtle weird behaviors, I
somehow ended up with an empty .designer.cs file for my aspx page. Which of
course is not only highly annoying, but completely build-breaking, since your
actual code-behind can't reference any controls that appear in the markup if
they're not declared for it in the designerfile.
I don't yet know why this is happening, but it of course doesn't fix itself
by adding or editing markup controls like you'd think it should. (if it did, it
probably wouldn't be screwing up in the first place!)
If you need to get the designer.cs file regenerated quickly (so as to, say,
be able to check in your work without breaking everyone's build when they get
latest), just:
- Delete the .designer.cs file
- Right-click on the aspx file in solution explorer
- Select "Convert to Web Application" if it appears in the context menu. (If
it doesn't, click around or twiddle your thumbs or something until VS realises
there's no designerfile anymore and repeat steps 2-3)
Voila, a regenerated designer file, and your code-behind starts working
again. (Until, of course, VS screws up again. It kept doing this to me continually all day. I wish you luck.)
I may or may not do a follow-up post on wtf is going on here, depending
mainly on whether or not I ever actually figure that out...