This documentation is archived and is not being maintained.

How to: Create a Visual Basic Test Project 

Visual Studio 2005

The following sections explain how to create and run the Visual Basic code example to automate Visual SourceSafe through the use of the IVSSDatabase interface that represents a Visual SourceSafe database.

Create a Visual Basic Test Project

To create a test project in Visual Basic do the following:

  1. Create a new SourceSafe database at c:\VSSTestDB.

    For details on how to create a new database, see How to: Log In to Visual SourceSafe.

  2. Open Visual Studio and, from the Start page, choose New Project.

  3. Select Visual Basic Projects from the tree view on the left side of the screen.

  4. Select Console Application as the project template.

  5. Set the name of the application to IVSSTestVB and click OK to create the project.

  6. Highlight the file called Module1.vb in the Solution Explorer window and rename it to PName.vb. Completely delete the code inserted by Visual Studio into this file.

  7. In IVSSTestVB project properties set Startup Object to Sub Main.

  8. To use the Primary Interop Assembly for the SSAPI.DLL COM component, select References under IVSSTest project, use right mouse button and then select Add Reference. Make sure that the .NET tab is selected, and use Select button to select IVSS Microsoft.VisualStudio.SourceSafe.Interop.dll Primary Interop Assembly. This will add the component to the Selected Components list.

  9. Click OK.

Add Sample Code

The following example demonstrates how to use the Name property of the IVSSItem interface.

  • Paste the code below into PName.vb.

    Imports System
    Imports Microsoft.VisualStudio.SourceSafe.Interop
    
    Imports System
    Imports Microsoft.VisualStudio.SourceSafe.Interop
    
    Module IVSSTest
    
        Public Sub Main()
    
            ' Create a VSSDatabase object.
            Dim vssDatabase As New VSSDatabase
    
            ' Open a VSS database using network name for automatic user login.
            vssDatabase.Open("C:\VSSTestDB\srcsafe.ini", Environment.UserName, "")
    
            ' vssFolder represents a SourceSafe project "TestFolder".
            Dim vssFolder As IVSSItem = vssDatabase.VSSItem("$/TestFolder", False)
    
            Console.WriteLine("'{0}' folder name is '{1}'", vssFolder.Spec, vssFolder.Name)
    
        End Sub
    
    End Module
    

Test the Application

To test the application do the following:

  • Press Control+F5 to build and run your application.

    The application output: '$/TestFolder' folder name is 'TestFolder'.

See Also

Show: