DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 315487 - Last Review: January 12, 2006 - Revision: 3.4

This article was previously published under Q315487

SUMMARY

The sample code provided in this article demonstrates how to use the LaunchWizard method of the DTE object to run an existing Microsoft Visual Studio .NET Wizard.

MORE INFORMATION

The DTE.LaunchWizard method requires two arguments when used to run a new project wizard. The first argument is the name of the wizard file (.vsz file). The second argument is an array of values that is passed to the wizard when it runs. When you set the seventh element of the array to True, you can force the errors to throw exceptions, which may be caught in a try...catch structure. The New Windows Application Wizard expects the following values in the array:
  • WizardType: a GUID indicating the type of wizard. For a new project wizard, the GUID is {0F90E1D0-4999-11D1-B6D1-00A0C90F2744}.
  • ProjectName: a string for the name of the new project.
  • Local directory: a string containing the full path to the folder where the new project will be created.
  • Installation directory: a string containing the folder where Visual Studio is installed.
  • Exclusive: a Boolean value indicating whether any existing open solution should be closed.
  • Solution name: a string name for the solution file, without a path or extension.
  • Silent: a Boolean indicating whether the wizard should run silently.
The following macro shows how to use the LaunchWizard method to run the existing wizard.

NOTE: The macro uses the Silent flag when calling the wizard. If you run this macro once, it runs without error, provided that the directory and project do not already exist. If you run this macro a second time, an error is raised. Because the Silent flag is set to True, an exception is caught by the try...catch block.
Sub LaunchWizardExample()

Dim params() As Object = New Object() 
{
   "{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}","NewProjectName1","NewProjectPath", "", False, "", False
}
'The last value is the "Silent" flag where TRUE=No UI, FALSE=UI

Dim res As EnvDTE.wizardResult
Dim s As String = DTE.Solution.TemplatePath(VSLangProj.PrjKind.prjKindCSharpProject)
Try
   res = DTE.LaunchWizard(s & "CSharpEXE.vsz",params)
Catch e1 As System.Exception
   System.Windows.Forms.MessageBox.Show("Caught an Exception: " + e1.Message)
End Try

End Sub
				
For additional information about the Wizard type, search on ContextParams Enum in Books Online.

REFERENCES

For more information about troubleshooting Visual Basic .NET and Visual C# extensibility, browse to the Microsoft Web Help file at the following Microsoft Web site:
http://msdn.microsoft.com/en-us/library/aa983744.aspx (http://msdn.microsoft.com/en-us/library/aa983744.aspx)

APPLIES TO
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition
Keywords: 
kbhowto KB315487
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support