Reference3 Interface

Extends the Reference2 interface of the VSLangProj2 namespace.

Namespace:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

[GuidAttribute("5021602E-2025-4299-88D2-0A92E8B41ADF")]
public interface Reference3 : Reference2

The Reference3 type exposes the following members.

  NameDescription
Public propertyAliasesGets or sets the aliased names for the specified reference. This property applies to Visual C# only.
Public propertyAutoReferencedGets whether the reference is automatically referenced by the compiler.
Public propertyBuildNumberGets the build number of the reference.
Public propertyCollectionGets a collection of References.
Public propertyContainingProjectGets the Project containing the reference.
Public propertyCopyLocalGets or sets whether the reference is copied to the local bin path.
Public propertyCultureGets the culture string of a reference.
Public propertyDescriptionGets a text description of the reference.
Public propertyDTEGets the top-level extensibility object.
Public propertyExtenderInfrastructure. Microsoft Internal Use Only.
Public propertyExtenderCATIDInfrastructure. Microsoft Internal Use Only.
Public propertyExtenderNamesInfrastructure. Microsoft Internal Use Only.
Public propertyIdentityGets the unique identifier of the reference.
Public propertyIsolatedGets or sets whether the COM reference is isolated, that is, not registered with Windows.
Public propertyMajorVersionGets the major version number of the reference.
Public propertyMinorVersionGets the minor version number of the reference.
Public propertyNameGets the name of the object.
Public propertyPathGets the path to the reference file.
Public propertyPublicKeyTokenGets the public key token from a strongly signed reference.
Public propertyRefTypeGets the type of reference: assembly, COM, or native.
Public propertyResolvedGets whether the current reference was resolved.
Public propertyRevisionNumberGets the revision number of the reference.
Public propertyRuntimeVersionGets the version of the runtime against which the reference was built. This is applicable only for .NET references.
Public propertySourceProjectGets a Project object if the reference is a project. Otherwise, it returns Nothing (a null object).
Public propertySpecificVersionGets or sets whether only a specific version of the reference is used.
Public propertyStrongNameGets whether the reference is signed with a public/private key pair.
Public propertySubTypeSets or Gets the assembly subtype.
Public propertyTypeObsolete. Included for backward compatibility only. Use RefType instead.
Public propertyVersionGets the version of the specified reference.
Top

  NameDescription
Public methodRemoveRemoves the reference from the References object that contains it.
Top

Reference3 defines the following new parameters:

Aliases

AutoReferenced

Isolated

RefType

SpecificVersion

The following example adds two references to an open Visual Basic or Visual C# project. It then calls a function, GetRefTypeName, to display the reference type and calls a function, ReportReferences, to display additional reference properties. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

The default paths for the added references are : <installation root>\Program Files\Microsoft.NET\Primary Interop Assemblies for adodb.dll, and <installation root>\Program Files\Common Files\SpeechEngines\Microsoft for spcommon.dll. Replace the <file path> in the example with these or other appropriate file paths.

using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    AddNewReference(((DTE2)applicationObject));
}

public void AddNewReference(DTE2 dte)
{
    Project aProject = null;
    VSProject2 aVSProject = null;
    aProject = applicationObject.Solution.Projects.Item(1);
    aVSProject = 
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    // Add an Assembly reference and display its type and a report.
    Reference3 newRef = null;
    // Replace <file path> with an actual file path.
    newRef = ((Reference3)(aVSProject.References.Add(@"
<file path>\adodb.dll")));
    MessageBox.Show("The " + newRef.Name + " added, is of type:" 
+ "\n" + GetRefTypeName(newRef));
    MessageBox.Show("A report on " + newRef.Name + ":" + "\n" 
+ ReportReferences(newRef)); 
    // Add a COM reference and display its type and a report.
    // Replace <file path> with an actual file path.
    newRef = ((Reference3)(aVSProject.References.Add(@"
<file path>\spcommon.dll")));
    MessageBox.Show("The " + newRef.Name + " added, is of type:" 
+ "\n" + GetRefTypeName(newRef));
    MessageBox.Show("A report on " + newRef.Name + ":" + "\n" 
+ ReportReferences(newRef)); 
}
private string GetRefTypeName(Reference3 refIdent)
{
    string type = null;
    switch (refIdent.Type)
    {
     case prjReferenceType.prjReferenceTypeActiveX:
        type = "COM";
        break;
    case prjReferenceType.prjReferenceTypeAssembly:
        type = "Assembly";
        break;
    }
    return type;
}
public string ReportReferences(Reference3 aRef)
{
    string report = "";
    string type = null;
    // Each entry in the ArrayList contains a label and a value.
    System.Collections.ArrayList ht = 
new System.Collections.ArrayList();
    VSLangProj.Reference temp = aRef;
    ht.Add(new string[] { "Name", temp.Name });
    ht.Add(new string[] { "Description", temp.Description });
   ht.Add(new string[] { "Version", string.Format("{0}.{1}.{2}.{3}"
, temp.MajorVersion, temp.MinorVersion, 
temp.BuildNumber, temp.RevisionNumber) });
    ht.Add(new string[] { "Location", 
temp.ContainingProject.FullName });
    switch (temp.Type)
    {
        case prjReferenceType.prjReferenceTypeActiveX:
            type = "COM";
            break;
        case prjReferenceType.prjReferenceTypeAssembly:
            type = "Assembly";
            break;
    }
    ht.Add(new string[] { "Type", type });
    ht.Add(new string[] { "Culture", temp.Culture });
    string[] datas = null;
    foreach (string[] temp1 in ht)
    {
        datas = temp1; 
        report += datas[0] + "\t" + datas[1] + "\n";
    }
    return report;
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft