我希望程序检查它是否已安装在计算机上(使用Clickonce)或仅运行(例如通过Visual Studio)。
编辑:不是How to detect that C# Windows Forms code is executed within Visual Studio?的副本。 “例如。”表示for example。
答案 0 :(得分:3)
您可以使用ApplicationDeployment.IsNetworkDeployed属性。请注意,这仅适用于ClickOnce安装。
private void CheckApplicationStatus() {
if (ApplicationDeployment.IsNetworkDeployed) {
// Do something that needs doing when the application is installed using ClickOnce.
} else {
// Do something that needs doing when the application is run from VS.
}
}