How to detect that C# Windows Forms code is executed within Visual Studio?

后端 未结 8 1934
春和景丽
春和景丽 2020-11-29 23:46

Is there a variable or a preprocessor constant that allows to know that the code is executed within the context of Visual Studio?

8条回答
  •  猫巷女王i
    2020-11-30 00:34

    I use this code to distinguish whether it's running in Visual Studio or if it's deployed to customers.

    if (ApplicationDeployment.IsNetworkDeployed) {
        // do stuff 
    } else {
       // do stuff (within Visual Studio)
    }
    

    Works fine for me for ages. I skip some logic when inside Visual Studio (such as logging in to application etc).

提交回复
热议问题