Jon Flanders' Blog

VS.NET 2005 (aka Whidbey) loses Template from the Add New Item dialog

Wednesday, June 02, 2004 9:55:52 PM (GMT Daylight Time, UTC+01:00)

Perhaps no one else is having this problem, but fairly regularly when I am working in VS.NET 2005 (the March version) doing Web Site projects, the Add New Item dialog is empty (there are no templates to select).  Sometimes closing devenv.exe fixes this, sometimes not.  So I wrote a macro that can be called from the Command Window that will add those items.  Another interesting thing (which I don't remember from 2002/2003) is that the only macros that will appear in the Command Window are macros that only have one parameter (perhaps I just missed this before).

Anyway - here is the macro in case anyone else needs it:

  Public Sub Add(ByVal subdir As String, ByVal templateName As String, ByVal fileName As String)
        Dim p As Project = DTE.Solution.Projects.Item(1) 
        templateName = String.Format("C:\Program Files\Microsoft Visual Studio 8\Web\WebNewFileItems\{0}{1}", subdir, templateName)
        Dim newFileName As String = fileName 
        p.ProjectItems.AddFromTemplate(templateName, newFileName)
  End Sub

Usage is :

Macros.MyMacros.Module1.AddASPX "|HtmlPage.htm|TableTest.htm"

or

Macros.MyMacros.Module1.AddASPX "CSharp|WebForm.aspx|Foo.aspx"

ASP.NET | VS.NET   #    Comments [1]   

Navigation

Book Code!!!

Books

Courses

Search

Subscribe

  • RSS 2.0
  • Add to Windows Live button
  • Add to Google button
  • Add to MyMSN button
  • Add to MyYahoo button
  • Add to Bloglines button
  • Add to Newsgator button