Solution3.Create 方法

在指定的目录中创建具有指定名称的空解决方案。

命名空间:  EnvDTE90
程序集:  EnvDTE90(在 EnvDTE90.dll 中)

语法

声明
Sub Create ( _
    Destination As String, _
    Name As String _
)
void Create(
    string Destination,
    string Name
)
void Create(
    String^ Destination, 
    String^ Name
)
abstract Create : 
        Destination:string * 
        Name:string -> unit
function Create(
    Destination : String, 
    Name : String
)

参数

  • Destination
    类型:String

    必需。 要在其中创建 .sln 和 .suo(解决方案)文件的目录。

  • Name
    类型:String

    必需。 显示在**“解决方案资源管理器”**中的名称。 这也是 .sln 和 .suo 文件的基名称。

示例

有关如何运行此外接程序代码的信息,请参见如何:编译和运行自动化对象模型代码示例

Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    CreateExample(_applicationObject)
End Sub

Sub CreateExample(ByVal dte As DTE2)
    ' This add-in creates a  solution.
    Try
        Dim soln As Solution3 =  _
        CType(_applicationObject.Solution, Solution3)
        MsgBox("Creating a new solution ")
        ' Make sure that the file path below exists on your computer.
        ' You can modify the path.
        soln.Create("c:\temp2", "ANewSoln.sln")
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using System.Windows.Forms;
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst,
 ref System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    CreateExample((DTE2)_applicationObject);
}
public void CreateExample(DTE2 dte)
{
    // This add-in creates a solution.
    try
    {
        Solution3 soln = (Solution3)_applicationObject.Solution;
        MessageBox.Show("Creating a  solution ");
        // Make sure that the file path below exists on your computer.
        // You can modify the path.
        soln.Create("c:\temp2", "ANewSoln2.sln");
    }
    catch(SystemException ex)
    {
    MessageBox.Show("ERROR: " + ex);
    }
}

.NET Framework 安全性

请参阅

参考

Solution3 接口

EnvDTE90 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例