“母版页文件……”无法加载” Visual Studio 2008 的错误

发布于 2024-10-16 13:00:31 字数 839 浏览 3 评论 0原文

我在 Windows Server 2008 上的 Visual Studio 2008 中创建了一个基本的 ASP.Net 项目。

它使用母版页进行核心设计,并具有一组从中继承的页面。

今天早上,我收到一条消息,说已安装更新,需要恢复我的一个文件。恢复完成后,我无法再在 Visual Studio Design 视图中打开页面,我只收到以下消息:

母版页错误

无法加载母版页文件“~/MyProject.Master”。

更正代码视图中的问题

但是据我所知,没有什么需要更正的。该文件与也继承相同母版页并正确显示的其他页面没有什么不同。将母版页更改为真正不存在的内容没有什么区别。将其改回真实的母版页也不起作用。

该页面在浏览器中正确显示,实际上似乎只有设计者有问题,并且仅在这一页面上。我在源代码管理历史记录中看不到可以解释此更改的任何更改。

由此出现的另一个问题是,如果我将新的 Asp.net 控件添加到“源”视图中的页面,它们不会自动连接到设计器类或隐藏代码中。

停止并重新启动 Visual Studio 似乎并没有改变情况。 VS.Net 是否可以在任何地方缓存此错误?

我能找到的唯一提到这一点的似乎是在非常旧的错误报告中 喜欢这个,但我找不到任何证据表明问题如何或是否得到解决,即使这些报告可以追溯到几年前。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不忘初心 2024-10-23 13:00:31

一段时间后我找到了解决方案。

首先,我关闭了项目中的所有文件并关闭了 Visual Studio。

然后我在命令行运行 devenv.exe /resetsettings 。我不确定我是否需要完成这部分,但这是我遵循的步骤。

然后我重新启动 Visual Studio,打开该项目,当我再次打开该文件时,它重新加载母版页并且可以正确显示它。

我怀疑是否可以在 Visual Studio 中重置项目特定的设置(当前打开的文件列表等),也能达到目的。

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.

孤独陪着我 2024-10-23 13:00:31

我也有同样的问题。我将一个现有网站添加到我的解决方案中,该解决方案现在有两个网站。卸载原始页面后,错误消失,我可以在设计器中查看页面。可能有一种方法可以解决这个问题,这样两个站点都可以在解决方案中并让设计人员工作,但我目前并不急于解决这个问题。

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.

对不⑦ 2024-10-23 13:00:31

我刚才也有同样的问题。我不想重置设置。我成功地重新启动 VS2012,然后清理解决方案,然后重新构建解决方案。我们有 3 个根母版页和 2 个子母版页,它们消耗根母版页之一。在进行干净的重建后,他们所有人都能够展示他们的设计师视图。

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.

ぇ气 2024-10-23 13:00:31

我刚刚在将旧网站项目的母版导入到 MVC 应用程序时遇到了这个问题。网站网站项目没有设计器文件,这会导致问题。

要生成它,请突出显示它,然后(在 VS 2015 中)转到项目菜单并选择转换为 Web 应用程序

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文