ASP.Net VirtualPathProvider and Visual Studio Intellisense

折月煮酒 提交于 2020-01-03 20:33:14

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5364129/asp-net-virtualpathprovider-and-visual-studio-intellisense

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!