Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AddAssemblyReference Method

AddAssemblyReference Method

Visual Studio .NET 2003

Adds an assembly (.NET) reference to the selected project.

[Visual Basic .NET]
Public Function AddAssemblyReference( _
   ByVal path As String _
) As Object
[Visual Basic 6]
Function AddAssemblyReference( _
   ByVal path As String _
) As Object
HRESULT __stdcall AddAssemblyReference(
   BSTR path,
   /* [out, retval] */ IDispatch** retVal
public object AddAssemblyReference(
   string path
[JScript .NET]
public function AddAssemblyReference(
   path : String
) : Object


A string representing the path of the assembly to add.

Return Value

The path of the assembly.


Adds a .NET assembly reference to your project based on the path to the assembly, if possible.

Imports EnvDTE
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine

Public Module Module1
    Sub Test()
        Dim prj As VCProject
        prj = DTE.Solution.Projects.Item(1).Object            
        If prj.CanAddAssemblyReference("d:\winnt\microsoft.net _
          \framework\v1.1.4322\envdte.dll") Then
           prj.AddAssemblyReference("d:\winnt\microsoft.net _
        End If
    End Sub
End Module

See Samples for Visual C++ Code Model Extensibility for information on how to compile and run this sample.

See Also

Applies To: VCProject Object | VCReferences Collection

© 2015 Microsoft