_DTE.LaunchWizard(String, Object[]) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
用提供的参数运行向导。
public:
EnvDTE::wizardResult LaunchWizard(System::String ^ VSZFile, cli::array <System::Object ^> ^ % ContextParams);
EnvDTE::wizardResult LaunchWizard(std::wstring const & VSZFile, std::Array <winrt::Windows::Foundation::IInspectable const &> const & & ContextParams);
[System.Runtime.InteropServices.DispId(232)]
public EnvDTE.wizardResult LaunchWizard (string VSZFile, ref object[] ContextParams);
[<System.Runtime.InteropServices.DispId(232)>]
abstract member LaunchWizard : string * Object[] -> EnvDTE.wizardResult
Public Function LaunchWizard (VSZFile As String, ByRef ContextParams As Object()) As wizardResult
参数
- VSZFile
- String
必需。 包含启动向导所需信息的 .Vsz(向导)文件。
- ContextParams
- Object[]
必需。 向导的参数。 第一个参数是唯一标识启动上下文,以使其不同于 Add Item 或 Add Project 的 GUID 或自定义的 GUID。 其余的参数是用户定义的,它们的数目和值取决于向导。
随 Visual Studio(如 Visual Basic Windows 应用程序或 Visual C# 控制台应用程序)一起提供的向导(或模板)有一组您必须传递给它们的上下文参数。 有关这些参数的详细信息,请参阅 ContextParams 枚举。 你创建的向导可以具有更多或更少的参数。
返回
wizardResult 对象。
- 属性
示例
Sub LaunchWizardExample()
Dim params() As Object = New Object() { _
"{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}", _ ' Param 0
"MyConsoleProject", _ ' Param 1
"C:\MyProjects", _ ' Param 2
"", _ ' Param 3
False, _ ' Param 4
"", _ ' Param 5
False} ' Param 6
' The wizardResult constant determines the state of the wizard, such
' as did it complete or was it canceled, etc.
Dim res As EnvDTE.wizardResult
' Set the project type to a Visual Basic project.
Dim s As String = _
DTE.Solution.TemplatePath(VSLangProj.PrjKind.prjKindVBProject)
' Launch the Visual Basic Console Application wizard using the
' supplied parameters. Any exceptions are caught below.
Try
res = DTE.LaunchWizard(s & "ConsoleApplication.vsz", params)
Catch e1 As System.Exception
MsgBox("Error: " & e1.Message)
End Try
End Sub
注解
IDE 的主 UI 线程与向导的执行同步,因此在向导完成之前,用户不能执行任何操作。
下面的宏示例演示如何使用 LaunchWizard 方法启动 " Visual Studio 添加项向导"。 此向导使用7个自定义参数,因此为每个参数设置值。 任何异常都由块捕获 Try...Catch 。