Solution2.Create Method
Creates an empty solution in the specified directory with the specified name.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
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
)
Parameters
Destination
Type: System.StringRequired. The directory in which to create the .sln and .suo (solution) files.
Name
Type: System.StringRequired. The name to display in Solution Explorer. This is also the base name of the .sln and .suo files.
Examples
For information on how to run this add-in code, see How to: Compile and Run the Automation Object Model Code Examples.
The following example shows how to create a solution.
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 Solution2 = _
CType(_applicationObject.Solution, Solution2)
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
{
Solution2 soln = (Solution2)_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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.