"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 inhe开发者_开发技巧riting 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.
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.
I had this same issue. I added an existing website to my solution which now has two web sites. After unloading the original one, the error went away and I was able to view the pages in the designer. There's probably a way to fix this so both sites can be in the solution and have the designer work, but I'm not that eager to figure that out at this point.
I had the same issue just now. I didn't want to reset settings. I had success restarting VS2012, then Clean Solution then Rebuild Solution. We have a 3 root master pages and 2 child master pages which consume one of the roots. All of them were able to show their designer view after doing a clean rebuild.
I just had this while importing the master from an old Web Site project into an MVC app. Web Site projects don't have a designer file, which causes the problem.
To generate it, highlight it then (in VS 2015) go to the Project menu and select Convert to Web Application.
精彩评论