Is there a variable or a preprocessor constant that allows to know that the code is executed within the context of Visual Studio?
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).
You can use this:
protected static bool IsInDesigner
{
get { return (Assembly.GetEntryAssembly() == null); }
}