VCProject.AddAssemblyReference(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds an assembly (.NET) reference to the selected project.
public:
System::Object ^ AddAssemblyReference(System::String ^ Path);
public:
Platform::Object ^ AddAssemblyReference(Platform::String ^ Path);
winrt::Windows::Foundation::IInspectable AddAssemblyReference(std::wstring const & Path);
[System.Runtime.InteropServices.DispId(841)]
public object AddAssemblyReference (string Path);
[<System.Runtime.InteropServices.DispId(841)>]
abstract member AddAssemblyReference : string -> obj
Public Function AddAssemblyReference (Path As String) As Object
Parameters
- Path
- String
A string representing the path of the assembly to add.
Returns
The path of the assembly.
- Attributes
Examples
See How to: Compile Example Code for Project Model Extensibility for information about how to compile and run this example.
Adds a .NET assembly reference to your project based on the path to the assembly, if possible.
' Add a reference to Microsoft.VisualStudio.VCProjectEngine and have a
' Visual C++ project loaded before running this example.
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine
Public Module Module1
Sub Test()
Dim prj As VCProject
Dim vcar As VCAssemblyReference
Dim refcfg As VCReferenceConfiguration
prj = DTE.Solution.Projects.Item(1).Object
If prj.CanAddAssemblyReference("C:\Program Files\ _
Microsoft Visual Studio 8\Common7\IDE\ _
PublicAssemblies\envdte.dll") Then
vcar = prj.AddAssemblyReference("C:\Program Files\ _
Microsoft Visual Studio 8\Common7\IDE\ _
PublicAssemblies\envdte.dll")
End If
refcfg = vcar.ReferenceConfigurations.Item(1)
MsgBox("Consumable? " & refcfg.ConsumableByDesigner)
End Sub
End Module
Remarks
AddAssemblyReference calls the VSCore service in Visual Studio to identify the MinFrameworkVersion
for the added reference. If you call AddAssemblyReference outside of Visual Studio where the VSCore service is not available, then the MinFrameworkVersion is set to eFrameworkVersionUnknown.