HOW TO: Create a Visual J# .NET Windows Application by Using Visual Studio Extensibility Features (324970)
The information in this article applies to:
- Microsoft .NET Framework 1.0
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual J# .NET (2002)
- Microsoft Visual J# .NET (2003)
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft .NET Framework 1.1
This article was previously published under Q324970 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 "References" section of
this article.)
Add the following sample code to the NewWindowProject
routine:
Dim template As String
Dim jSharpProjectGuid as String = "{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}"
template = DTE.Solution.TemplatePath(jSharpProjectGuid) & "VJSharpEXE.vsz"
- 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("New name:")
newProject = DTE.Solution.AddFromTemplate(template, "c:\" & name, name, True)
The following sample code is the complete macro:
Sub NewWindowProject()
Dim template As String
Dim jSharpProjectGuid As String = "{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}"
template = DTE.Solution.TemplatePath(jSharpProjectGuid) & "VJSharpEXE.vsz"
Dim newProject As Project
Dim name As String = InputBox("New name:")
newProject = DTE.Solution.AddFromTemplate(template, "c:\" & name, name, True)
End Sub
- Save the macro, close the Macros IDE, and then run the
macro from Macro Explorer.
back to the top
REFERENCES The following is a complete list of Visual J# .NET Project
Template types:
- VJSharpConsole.vsz - Console Application
- VJSharpControl.vsz - Windows Form Control
- VJSharpDLL.vsz - DLL
- VJSharpemptywebproj.vsz - Empty Web Project
- VJSharpEXE.vsz - Windows Form Application
- VJSharpWebApp.vsz - Web Application
- VJSharpWebControl.vsz - Web Control
- VJSharpWebService.vsz - Web Service
- VJSharpWinService.vsz - Windows Service
back to the top
Modification Type: | Major | Last Reviewed: | 8/7/2003 |
---|
Keywords: | kbHOWTOmaster KB324970 kbAudDeveloper |
---|
|