この質問を再検討すると、これを行う 5 つの異なる方法が「発見」されました。
System.ComponentModel.DesignMode property
System.ComponentModel.LicenseManager.UsageMode property
private string ServiceString()
{
if (GetService(typeof(System.ComponentModel.Design.IDesignerHost)) != null)
return "Present";
else
return "Not present";
}
public bool IsDesignerHosted
{
get
{
Control ctrl = this;
while(ctrl != null)
{
if((ctrl.Site != null) && ctrl.Site.DesignMode)
return true;
ctrl = ctrl.Parent;
}
return false;
}
}
public static bool IsInDesignMode()
{
return System.Reflection.Assembly.GetExecutingAssembly()
.Location.Contains("VisualStudio"))
}
提案された 3 つのソリューションを試してみるために、3 つのプロジェクトで小さなテスト ソリューションを作成しました。
- TestApp (winforms アプリケーション)、
- サブコントロール (dll)
- サブサブコントロール (dll)
次に、SubSubControl を SubControl に埋め込み、それぞれを TestApp.Form に埋め込みました。
このスクリーンショットは、実行時の結果を示しています。

このスクリーンショットは、Visual Studio でフォームを開いた結果を示しています。

結論:リフレクションなしでは、コンストラクター内で信頼できるのは LicenseUsage だけであり、コンストラクターの外部で信頼できるのは「IsDesignedHosted」だけです (以下のBlueRajaによる)。
PS: 以下のToolmakerSteveのコメントを参照してください (私はテストしていません):結果をキャッシュします。」