Reference3.CopyLocal Property
Gets or sets whether the reference is copied to the local bin path.
Namespace: VSLangProj80
Assembly: VSLangProj80 (in VSLangProj80.dll)
Syntax
'Declaration
Property CopyLocal As Boolean
bool CopyLocal { get; set; }
property bool CopyLocal {
bool get ();
void set (bool value);
}
abstract CopyLocal : bool with get, set
function get CopyLocal () : boolean
function set CopyLocal (value : boolean)
Property Value
Type: System.Boolean
A boolean value indicating whether the reference is copied.
Remarks
At run time, a reference must exist in either the global assembly cache or the output path of the project. If this property is set to true, the reference is copied to the output path of the project at run time.
At run time, assemblies must be in one of two locations: the output path of the project or the global assembly cache (see Working with Assemblies and the Global Assembly Cache). If the project contains a reference to an object that is not in one of these locations, then when the project is built, the reference must be copied to the output path of the project. The CopyLocal property indicates whether this copy needs to be made. If the value is true, the reference is copied. If false, the reference is not copied.
The common language runtime does not track changes to the reference to determine if the local copy needs to be updated. Changes are tracked by the project system. As long as the user has not overridden the CopyLocal property, the value is automatically updated by the project system if needed.
The project-assigned value of the CopyLocal property is determined in the following order:
If the reference is another project, called a project-to-project reference, then the value is true.
If the reference is a Visual Studio .NET Framework assembly, then the value is false.
If the reference's assembly matches a Visual Studio .NET Framework assembly’s strong name except for version number (such as Visual Studio 2003 assemblies, for example), then the value is false.
If the reference's assembly is in the .NET Framework directory, then the value is false.
If the reference's assembly is in the GAC, then the value is false.
Otherwise, the value is true.
Note that number 4 above is not the same as number 3 because the .NET Framework SDK folder is not the same thing as the .NET Framework directory.
Examples
This example displays the CopyLocal values for all references in an open Visual Basic or Visual C# project. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.
Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
applicationObject = CType(application, DTE2)
addInInstance = CType(addInInst, AddIn)
DisplayCopyLocalValues(applicationObject)
End Sub
Public Sub DisplayCopyLocalValues(ByVal dte As DTE2)
' The first project is a Visual Basic or C# project.
Dim vsProject As VSProject2 = _
CType(applicationObject.Solution.Projects.Item(1).Object, _
VSProject2)
Dim aRef As Reference3
Dim refStr As String
refStr = ""
For Each aRef In vsProject.References
refStr += (aRef.Name & "'s CopyLocal value is: " & _
aRef.CopyLocal.ToString() & vbCr& vbCr)
Next
MsgBox(refStr)
End Sub
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;
DisplayCopyLocalValues(((DTE2)applicationObject));
}
public void DisplayCopyLocalValues(DTE2 dte)
{
// The first project is a Visual Basic or C# project.
VSProject2 vsProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
Reference aRef = null;
string refStr = null;
refStr = "";
foreach (VSLangProj80.Reference3 temp in vsProject.References)
{
aRef = temp;
refStr += (aRef.Name + "'s CopyLocal value is: "
+ aRef.CopyLocal.ToString() + "\n" + "\n");
}
MessageBox.Show(refStr);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.