Search code examples
asp.netvisual-studio-2008master-pages

"The Master Page file '....' cannot be loaded" error from Visual Studio 2008


I have a basic ASP.Net project created in Visual Studio 2008 on Windows Server 2008.

It uses a Master Page for the core design and has a set of pages inheriting from that.

This morning I came in to a message saying an update had been installed and one of my files needed to be recovered. When the recovery was complete, I could no longer open the page in the Visual Studio Design view, I just get the following message:

Master Page Error

The Master Page file '~/MyProject.Master' cannot be loaded.

Correct the problem in Code View

There is, however nothing to correct so far as I can see. The file is no different to other pages that also inherit the same Master page and display correctly. Changing the Master page to something that genuinely doesn't exist makes no difference. Neither does changing it back to the real Master page.

The page displays correctly in the browser, it is literally only the designer that seems to have the problem and only on this one page. I can see no changes in the Source Control history that would explain this change.

The other problem that appears to happen as a consequence is that if I add new Asp.net controls to the page in the Source view, they don't get automatically wired up into the designer class or the codebehind.

Stopping and restarting Visual Studio does not seem to have changed matters. Is there anywhere this error could be getting cached by VS.Net?

The only mentions of this I can find seem to be in very old bug reports like this one but I can't find any evidence of how or whether the issue was solved even though the reports go back a few years now.


Solution

  • I found a solution, after some time.

    First I closed all files in the project and closed the Visual Studio.

    Then I ran devenv.exe /resetsettings at the command line. I don't know for sure that I needed to do this part but it was a step that I followed.

    Then I restarted Visual Studio, opened the project and when I opened the file again it reloaded the master page and it could display it properly.

    I suspect if one could reset the project-specific settings - the list of which files are currently open and so on - in Visual Studio that would do the trick as well.