ASP.Net VirtualPathProvider 和 Visual Studio Intellisense

发布于 2024-10-23 19:07:22 字数 626 浏览 13 评论 0原文

我希望有人能帮我解决这个烦恼。

在工作中,我们有两个独立的网站项目,它们共享一个公共母版页。 MasterPage 嵌入到两个项目都引用的类库中。我们使用自定义 VirtualPathProvider,让我们可以在每个项目中引用 MasterPage。这在运行时/编译时工作得很好,但它破坏了 aspx 页面标记内的智能感知。

当我将 MasterPageFile 属性设置为“~/EmbeddedMasterPage.Master”时,Visual Studio 在其下方显示红色波浪线错误,指出“未找到路径”,并显示一个目录,表明它正在尝试在网站项目中查找该文件(而不是类库项目)。由于 Visual Studio 无法确定 MasterPage 的位置,因此会导致所有智能感知中断。它不会显示标签的任何内容。事实上,它给我的唯一智能感知是基本的 html 标签。通过谷歌搜索,我能找到的唯一信息是 VS 无法在嵌入的 MasterPage 中找到根 html/head/body 标记。但我找不到解决方法。

这种情况在 Visual Studio 2008 和 2010 中都会发生。

更新 (4/10/2011)

目前,我必须将嵌入的母版页复制到实际的站点项目中才能将其工作。我将文件设置为不编译/复制,结果正常。

I'm hoping someone can help me out with this annoyance.

At work we have two independent website projects that share a common MasterPage. The MasterPage is embedded in a class library that both projects reference. We use a custom VirtualPathProvider that lets us reference the MasterPage in each project. This works fine at runtime/compiletime, but it breaks intellisense inside the aspx page markup.

When I set the MasterPageFile property to "~/EmbeddedMasterPage.Master", Visual Studio shows a red squiggley error under it saying "Path not found", with a directory indicating that it's trying to find that file inside the website project(as opposed to the class library project). Since Visual Studio can't figure out where the MasterPage is, it's causing all of the intellisense to break. It won't show anything for the tags. In fact, the only intellisense it will give me is for basic html tags. From Googling around, the only information I could find is that VS can't find the root html/head/body tags in the embedded MasterPage. I couldn't find a way to fix it, though.

This happens in both Visual Studio 2008 and 2010.

Update(4/10/2011)

For the time being, I'm having to copy the embedded masterpage to the actual site project in order to get it to work. I set the file to not compile/copy and it works out ok.

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

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

发布评论

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

评论(1

独享拥抱 2024-10-30 19:07:22

VirtualPathProvider 需要运行时环境。在设计时,这是不可用的,因此无法让 IDE 通过 VirtualPathProvider 找到它。

我认为您的更新是最好的解决方法。

The VirtualPathProvider requires the run-time environment. During design time this is not available, so there is no way to get the IDE to find it via VirtualPathProvider.

I think your update is the best workaround.

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