Microsoft KB Archive/324970

= HOW TO: Create a Visual J# .NET Windows Application by Using Visual Studio Extensibility Features =

Article ID: 324970

Article Last Modified on 8/7/2003

-

APPLIES TO


 * Microsoft .NET Framework 1.0
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual J# .NET 2003 Standard Edition
 * Microsoft Visual J# .NET 2003 Standard Edition
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft .NET Framework 1.1

-



This article was previously published under Q324970



IN THIS TASK
SUMMARY
 * Create a Visual J# .NET Windows Application

REFERENCES



SUMMARY
Extensibility features of Visual Studio .NET allow you to automate common tasks in the IDE. This step-by-step article describes how to use these features to automate tasks for creating a new Visual J# .NET Windows application.

back to the top

Create a Visual J# .NET Windows Application
Create a macro named CreateProject that prompts the user for a project name, and then generates a new Visual J# .NET Windows Application Project.  In the Visual Studio .NET IDE, create a new macro project. To do this, on the Tools menu, point to Macros, and then click New Macro Project. Name the project MyMacroProject, and then click Open. A new Macro project is created that has one module named Module1.  In Macro Explorer, right-click Module1, and then click New macro. The Macro IDE opens, and a new subroutine named Macro1 is created. Replace Macro1 with the following sample code: Sub NewWindowProject ' Add code here to create new project End Sub In the following steps, you add code to this function.   The GUID that is used to reference all Visual J# .NET projects is {E6FDF86B-F3D1-11D4-8576-0002A516ECE8}. This GUID is passed to the TempatePath method, which returns the requested template. The template file that is used for Visual J# .NET Windows applications is VJSharpEXE.vrz. (For a full list of Visual J# .NET project templates, see the &quot;References&quot; section of this article.)

Add the following sample code to the NewWindowProject routine: Dim template As String Dim jSharpProjectGuid as String = &quot;{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}&quot; template = DTE.Solution.TemplatePath(jSharpProjectGuid) & &quot;VJSharpEXE.vsz&quot;   Call the AddFromTemplate method (Solution Object). In this case, the project name is obtained from the user, and is used as both the project location and the project name. To do this, paste the following code to the NewWindowProject routine: Dim newProject As Project Dim name As String = InputBox(&quot;New name:&quot;) newProject = DTE.Solution.AddFromTemplate(template, &quot;c:\&quot; & name, name, True) The following sample code is the complete macro: Sub NewWindowProject Dim template As String Dim jSharpProjectGuid As String = &quot;{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}&quot; template = DTE.Solution.TemplatePath(jSharpProjectGuid) & &quot;VJSharpEXE.vsz&quot; Dim newProject As Project Dim name As String = InputBox(&quot;New name:&quot;) newProject = DTE.Solution.AddFromTemplate(template, &quot;c:\&quot; & name, name, True) End Sub  Save the macro, close the Macros IDE, and then run the macro from Macro Explorer.

back to the top

