Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace Test
- {
- public class ComponentClass : Component
- {
- public ComponentClass()
- {
- MessageBox.Show("Runtime!");
- }
- }
- }
- using System;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace Test
- {
- public class ComponentClass : Component
- {
- public ComponentClass()
- {
- if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
- {
- MessageBox.Show("Runtime!");
- }
- }
- }
- }
- public static bool DesignMode
- {
- get { return (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv"); }
- }
- if (!DesignMode)
- {
- // Run code that breaks in VS Designer (like trying to get a DB connection)
- }
- public static bool IsAnyInDesignMode(Control control){
- while(control != null){
- if(control.Site != null && control.Site.DesignMode)
- return true;
- control = control.Parent;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment