ItemOperations.AddNewItem no longer functions

Hello,

I had written a number of extensive macros for the 2003 IDE and I would like to carry them over to 2005. The only error I encounter is when the macros are attempting to create a new class file using the ItemOperations.AddNewItem Function. In VB.NET 2003, I could use this syntax:


Dim doc As ProjectItem = DTE.ItemOperations.AddNewItem("Local Project Items\Class", DocName & EXTENSION)
 


With VS.NET 2005, I receive a COM error that the item could not be located.

The documentation says to use the name from the left of the Add New Item dialog, and the item from the right to create the name, but the new Add New Item dialog no longer has a right/left. (BTW, The AddNewItem call works fine when I'm in a non-vb project, such as a web project. The Add New Item dialog for these project types does contain a left/right pane to decipher from).

If anyone has any ideas what the correct item type is for a VB class, I would appreciate it, or if they have another method for creating a blank class, that would work just as well.

Thanks in advance,
OwenG


Answer this question

ItemOperations.AddNewItem no longer functions

  • Ed Jarrett

    Thanks Mike for getting back to me on this one. I had no clue where to begin.

    -OwenG

  • Uriparan

    Hi Owen,

    in addition to the above, I wanted to describe how the names "Visual Basic Items" and "Visual C# project Items" are found above.

    The following registry key is opened
    HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Projects\{F184B08F-C81C-45f6-A57F-5ABD9991F28F}\AdditemTemplates\TemplateDirs\{164B10B9-B200-11D0-8C61-00A0C91E29D5}\ /1
    default value #3082

    {F184B08F-C81C-45f6-A57F-5ABD9991F28F} = VB Project guid
    {164B10B9-B200-11D0-8C61-00A0C91E29D5} = Visual Basic Project System Package guid
    the package guid above is useful to find out the satellite dll name where the resource is found.  Look in HKLM\Software\Microsoft\VisualStudio\8.0\Packages\{164B10B9-B200-11D0-8C61-00A0C91E29D5}\SatelliteDll Named value DllName
    #3082 = resource id in satellite dll

    If you open up msvbprjui.dll in Visual Studio using the Resource editor (Open File -> Open File Dialog -> Open -> Open With)

    Go to the string table and look at resource id 3082, it is set to Visual Basic Items.

    The same would apply to the VC# project system except it would be resource id 2346.

    I will report this with the doc team to see if we can get the explicit names in the docs to make it more easily discoverable.

    Thanks!
    mike

  • BJBear

    Hi Owen,

    I wanted to quickly post what I found so far.  The following should work depending on the language project loaded

    AddNewItem("Visual Basic Items\Class", "test.vb")
    AddNewItem("Visual C# Project Items\Class", test.cs");

    I will post more after I dig deeper into the actual AddNewItem method to see how to get the first parameter in a more generic sense.

    thanks!
    mike


  • ItemOperations.AddNewItem no longer functions