如何解决Visual Studio 2005 "The Directory Name is Invaild" 错误

今天用vs2005 做一个web 程序时发现当试图更改控件ID时,总是出现"The Directory Name is Invaild" 错误提示。

以前曾遇到一次,忘了如何解决了。于是上网搜了搜发现在codeproject上一个老外也遇到同样问题,这是他的解决方法。
http://www.codeproject.com/useritems/VsPropRenameBug.asp

Workaround

1. Navigate to the directory
..\Documents and Settings\<%UserName%>\Local Settings\Application Data\Microsoft\WebsiteCache

2. Create a folder with the same name as the name of your project

看到WebsiteCache ,突然想起上次如何解决这个问题。

1. 按上面路径找到WebsiteCache 目录
2. 打开Websites.xml文件,内容类似如下:

<?xml version="1.0" encoding="utf-16"?>
<DesignTimeData>
  
<Website RootUrl="http://Localhost/net2005test1/" CacheFolder="net2005test1" startpage="Default.aspx" addnewitemlang="Visual C#" addnewitemoptions="2" startaction="1" _LastAccess="10/18/2006 9:02:49 AM"/>
  
<Website RootUrl="http://Localhost/CssAdaptersTutorial/" CacheFolder="CssAdaptersTutorial" addnewitemlang="Visual C#" _LastAccess="11/1/2006 2:04:34 PM"/>
 
</DesignTimeData>
3.删除有问题的website标记段
4.重新打开web程序在vs2005, 控件id可以更改,问题解决。

写道这里突然想到应到微软bug report查查, 果然是bug。会在vs下一版本或service pack里解决。
避免错误的方法就是不要同时用vs2005打开多个web程序,否则他们的cache 就晕了


http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101992

This problem should only occur if you have multiple instances of the Visual Studio IDE open at the same time and then close one. You can avoid this problem by only having one instance open at a time.

A fix has been created for this bug. The fix will be in the next version of Visual Studio or possibly in a service pack. If this bug is significantly impacting your development you should contact Microsoft Product Support to request a hot fix.

Microsoft Web Development Tools Team

Posted by Microsoft on 2/15/2006 at 2:30 PM
Clarification for user comments:

The underlying problem is that if the WebSiteCache directory for a specific web site is deleted this problem will occur. Once the directory is deleted it will continue to occur even if you reboot the machine.

There is a bug in Visual studio that when you have more than one instance of the IDE open and close a web-site it will delete the WebSiteCache directory of other web-sites. This is the common way to get into this situation. However, you could also get into the situation by deleting the directory manually (per the repro steps of this bug report.)

The quick fix is to make VS re-build the web site cache:
a) shut down all instances of VS
b) remove cache from command prompt> rd /s /q "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache"
c) re-open your web site and the cache will be re-created

An alternative method to fix the one web site without deleteing the entire cache is the following:
a) shut down all instances of VS
b) open "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache\websites.xml"
c) locate the entry for your web site and get its CacheFolder name. Usually the name of the web.
d) Ensure a sub-directory of that name exists under "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache\"

原文地址:https://www.cnblogs.com/patrick/p/561227.html