次の方法で共有


VCProject.CanAddAssemblyReference メソッド

指定したアセンブリ (.NET) 参照を追加できるかどうかを返します。

名前空間:  Microsoft.VisualStudio.VCProjectEngine
アセンブリ:  Microsoft.VisualStudio.VCProjectEngine (Microsoft.VisualStudio.VCProjectEngine.dll 内)

構文

'宣言
Function CanAddAssemblyReference ( _
    bstrRef As String _
) As Boolean
bool CanAddAssemblyReference(
    string bstrRef
)
bool CanAddAssemblyReference(
    [InAttribute] String^ bstrRef
)
abstract CanAddAssemblyReference : 
        bstrRef:string -> bool 
function CanAddAssemblyReference(
    bstrRef : String
) : boolean

パラメーター

戻り値

型: System.Boolean
指定のアセンブリ (.NET) 参照を追加できる場合は true、それ以外の場合は false です。

解説

たとえば、GUID が無効な場合は、アセンブリ参照を追加できません。

通常、このメソッドは、AddAssemblyReference メソッドと共に使用します。 このメソッドを使用してアセンブリ参照を追加できるかどうかを調べ、追加できる場合は、AddAssemblyReference を呼び出します。

このサンプル コードをコンパイルして実行する方法については、「方法 : Visual C++ コード モデル機能拡張のプログラム例をコンパイルする」を参照してください。

CanAddAssemblyReference は、アセンブリのパスに基づいて、プロジェクトに .NET アセンブリ参照を追加します (可能な場合)。

' 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

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

VCProject インターフェイス

Microsoft.VisualStudio.VCProjectEngine 名前空間