VCProject.CanAddAssemblyReference - метод
Returns whether it is okay to add the given assembly (.NET) reference.
Пространство имен: Microsoft.VisualStudio.VCProjectEngine
Сборка: Microsoft.VisualStudio.VCProjectEngine (в Microsoft.VisualStudio.VCProjectEngine.dll)
Синтаксис
'Декларация
Function CanAddAssemblyReference ( _
bstrRef As String _
) As Boolean
'Применение
Dim instance As VCProject
Dim bstrRef As String
Dim returnValue As Boolean
returnValue = instance.CanAddAssemblyReference(bstrRef)
bool CanAddAssemblyReference(
string bstrRef
)
bool CanAddAssemblyReference(
[InAttribute] String^ bstrRef
)
function CanAddAssemblyReference(
bstrRef : String
) : boolean
Параметры
bstrRef
Тип: System.StringThe assembly reference.
Возвращаемое значение
Тип: System.Boolean
true if whether it is okay to add the given assembly reference; false if not.
Заметки
It would not be okay to add an assembly reference if, for example, you have an invalid GUID.
This method is generally used in tandem with the AddAssemblyReference method. You use this method to determine whether it is okay to add an assembly reference, and if it is, then you call AddAssemblyReference.
Примеры
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information about how to compile and run this example.
CanAddAssemblyReference 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
Разрешения
- Полное доверие для непосредственно вызывающего метода. Этот член не может быть использован частично доверенным кодом. Дополнительные сведения см. в разделе Using Libraries from Partially Trusted Code.