Reference3.BuildNumber 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取引用的生成号。
public:
property int BuildNumber { int get(); };
public:
property int BuildNumber { int get(); };
[System.Runtime.InteropServices.DispId(14)]
public int BuildNumber { [System.Runtime.InteropServices.DispId(14)] get; }
[<System.Runtime.InteropServices.DispId(14)>]
[<get: System.Runtime.InteropServices.DispId(14)>]
member this.BuildNumber : int
Public ReadOnly Property BuildNumber As Integer
属性值
一个长整型值。 返回的值取决于引用类型。引用 TypeValue ReturnedAssemblyBuild number of reference;0-9999. COM0
实现
- 属性
示例
此示例将程序集和 COM 引用添加到打开的 Visual Basic 或 Visual C# 项目中,并在消息框中显示每个引用的生成号。 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例。
添加的引用的默认路径为: <installation root> \Program Files\Microsoft.NET\Primary 互操作程序集用于 adodb.dll 和 <installation root> \Program Files\Common Files\SpeechEngines\Microsoft for spcommon.dll。 <file path>将示例中的替换为这些或其他相应的文件路径。
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)
AddRefPlusBuild(applicationObject)
End Sub
Sub AddRefPlusBuild(ByVal dte As DTE2)
Dim aProject As Project
Dim aVSProject As VSProject2
aProject = applicationObject.Solution.Projects.Item(1)
aVSProject = _
CType(applicationObject.Solution.Projects.Item(1).Object, VSProject2)
' Add an assembly reference and display its build number.
Dim newRef As Reference3
' Replace <file path> with an actual file path.
newRef = aVSProject.References.Add("<file path>\adodb.dll")
MsgBox("The " & newRef.Name() & " has a build number:" & vbCr _
& newRef.BuildNumber.ToString())
' Add a COM reference and display its build number. Should be 0.
' Replace <file path> with an actual file path.
newRef = aVSProject.References.Add("<file path>\spcommon.dll")
MsgBox("The " & newRef.Name() & " has a build number:" & _
vbCr & newRef.BuildNumber.ToString())
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;
AddRefPlusBuild(((DTE2)applicationObject));
}
public void AddRefPlusBuild(DTE2 dte)
{
Project aProject = null;
VSProject2 aVSProject = null;
aProject = applicationObject.Solution.Projects.Item(1);
aVSProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
// Add an Asembly reference and display its build number.
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.ToString() +
" has a build number:" + "\n" + newRef.BuildNumber.ToString());
// Add a COM reference and display its build number.
// Replace <file path> with an actual file path.
newRef = ((Reference3)(aVSProject.References.Add(@"
<file path>\spcommon.dll")));
MessageBox.Show("The " + newRef.Name.ToString() + " has a build
number:" + "\n" + newRef.BuildNumber.ToString());
}
注解
BuildNumber属性获取版本号的 生成 组件。 引用的版本由四个组件唯一标识: 主要 版本号、 次要 版本号、 内部 版本号和 修订 版本。 主要 和 次要 组件是必需的。 如果未定义 build ,则 修订版本 组件是可选的。 COM 对象没有 修订版本 和 生成 组件。 有关详细信息,请参阅程序集版本控制。