You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be no reliable way to detect that custom UserControl is running in Visual Studio Designer.
For years, this solution used to work, and still works for net framework .48
Unfortunately, with out of process designer and .net 8 it doesn't.
We need a better way to detect when user code is in VS designer.
Stop designer from running code it shouldn't run
Provide designer data (wpf style), so I can preview code without running it.
// Source - https://stackoverflow.com/a/2849244
// Posted by Jonathan, modified by community. See post 'Timeline' for change history
// Retrieved 2026-04-29, License - CC BY-SA 3.0
public MyUserControl()
{
InitializeComponent();
m_IsInDesignMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
}
private bool m_IsInDesignMode = true;
public bool IsInDesignMode { get { return m_IsInDesignMode; } }
Current workaround requires this solution everywhere.
Just make a method or property inside SDK
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
There seems to be no reliable way to detect that custom UserControl is running in Visual Studio Designer.
For years, this solution used to work, and still works for net framework .48
Unfortunately, with out of process designer and .net 8 it doesn't.
We need a better way to detect when user code is in VS designer.
Current workaround requires this solution everywhere.
Just make a method or property inside SDK
#10960 (comment)
Key problems with current soluitions
Related:
Beta Was this translation helpful? Give feedback.
All reactions