If you have used Visual Studio 2005 for any length of time, particularly if you have installed the .NET 3.0 bits in either Beta or Release form, you may have suddenly seen some or all of your project templates in the New Project dialog disappear!
I wrote about this and a related issue before but this time around the fix was not so simple. I had installed the WWF and WCF bits along with the .NET 3.0 SDK. Somewhere in the process I lost the Windows Application template for VB.NET.
This lead me to try a number of potential fixes outlined in this blog post on Eric Hammersley's blog. None of the fixes outlined there helped. Neither did uninstalling and reinstalling Visual Studio itself. I also uninstalled the 3.0 bits, all add-ins, etc.
So I started doing some digging, the way the templates, at least the stock ones, seem to work is that there is a series of directories in this folder: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
The ones of interest are: ProjectTemplates, ProjectTemplatesCache, ItemTemplates, ItemTemplatesCache.
The Templates directories contain the "Master" copies, the Cache versions of the folders contain the copies that are displayed in the New Project or Add Item dialog boxes. They are normally identical.
The command devenv /InstallVSTemplates run from a Visual Studio command prompt should sync the directories up. But this had not happened on my system. Repeated execution of the command resulted in no change.
Then I began to wonder, after all I am running Vista, even though I had made my account a member of the Administrators group to resolve this issue (not recommended by the way), I remembered that on Vista that was actually only making me an "almost" administrator.
So I logged in as the real administrator account, opened a Visual Studio Command Prompt and executed the devenv /InstallVSTemplates command and this time the hard drive lit up and there was a perceptible delay before the command prompt reappeared.
I logged out, logged back in as my own account and launched Visual Studio and the templates were back again!
Further spelunking in the Application event log showed that about two days before Visual Studio had started to complain that my cache directories were not in sync, and that several templates were missing their templatename.vstemplate files.
Templates are a basically zip files which include a vstemplate file that captures the references and directory structure of the template when it is expanded and created. Something had corrupted the cache copies and apparently I did not have enough rights to copy the originals over top of the cache copies.
More disturbing was that reinstalling Visual Studio did not fix the issue! But whatever the reason the files became damaged, logging in as administrator resolved the issue.
Hope this helps someone else!
Cheers,
Robert Porter
UPDATE: I forgot to mention, don't try just copying the directories from the master copies into the cache folders. There is more involved than a simple copy operation and if you just physically copy the files you will lose ALL of your templates. I know, I tried.