In case you hadn't noticed, there is a Beta of SP1 for Visual Studio 2008 and .NET Framework 3.5 out there. You should really check it out, it has tons of goodies, especially if you need some performance boosts in your WPF applications.
In this blog, I want to highlight a little hack that Microsoft added to the designer. In some instances, with complex nested Web Application Project solutions, the 2008 designer can not locate the master page. This used to be the case in 2005 designer too, but it would just show an error message for the master page portion of the form, and still show the content page. But in 2008, the content page is not displayed either, so you cant use the designer at all. I reported this to Microsoft and they were kind enough to provide a workaround. I just tested it out and it worked really well.
Our project has the following structure:
/root (web application project)
/root/module 1 (web application project)
/root/module 2 (web application project)
/root/module n (web application project)
/root/lib projects (class library projects)
/root/UI (web application project)
The master page resides in /root/UI.
It is referenced by content pages in all of the /module x projects, which are sibling directories to the UI directory, and all under the root web app directory. The master page is referenced "~/UI/xxx.Master". This is the reference that does not work in design time (as ~ is resolved to be the local module x web app root in design time, but in runtime it correctly resolves to the global app root).
So here is the work around:
- I made a copy of the master page and placed it in the root directory
- I renamed it __fallback.Master (this is a magic word, needs to be exactly this), also renaming the code behind and designer files too (__fallback.Master.cs and __fallback.Master.designer.cs)
- I included the copied master page in the root web application project (it didn't work without this step)
- I adjusted URLs in the copy to reflect its new location
- Now, it worked in design time! But not in run time, because there were two classes with the same name, so I edited the copied master page and changed the class name to FallBackXXX.master - you can choose any name, the class will never be used in runtime)
That did it! Of course, you could use any old master page for the fake __fallback page, even just a blank one, but if you want it to look like it should in design time, it is better to use a modified copy of your actual master page as detailed above.
Thanks Microsoft for the workaround!