Application.ProductVersion 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取与该应用程序关联的产品版本。
public:
static property System::String ^ ProductVersion { System::String ^ get(); };
C#
public static string ProductVersion { get; }
member this.ProductVersion : string
Public Shared ReadOnly Property ProductVersion As String
产品版本。
下面的代码示例获取此属性,并在文本框中显示其值。 该示例要求 textBox1
已放置在窗体上。
private:
void PrintProductVersion()
{
textBox1->Text = "The product version is: {0}",
Application::ProductVersion;
}
C#
private void PrintProductVersion() {
textBox1.Text = "The product version is: " +
Application.ProductVersion;
}
Private Sub PrintProductVersion()
textBox1.Text = "The product version is: " & _
Application.ProductVersion
End Sub
通常,版本号显示为 主编号。次要编号。内部版本号。专用部件号。 可以通过在程序集清单中设置程序集版本来显式设置它。 有关详细信息,请参阅 程序集清单。
ProductVersion 首先查看包含主可执行文件的程序集是否具有 AssemblyInformationalVersion
该程序集的属性。 如果此属性存在,则用于这两个 ProductVersion 属性和 CommonAppDataPath。 如果此属性不存在,则这两个属性都改用可执行文件的版本。
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |