Tag: forms

在C#中运行Powershellscript

我试图在Windows窗体中通过C#运行PowerShell脚本。 问题是我有两个枚举,我无法在代码中得到它们: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using System.Collections.ObjectModel; using System.Management.Automation; using System.Management.Automation.Runspaces; namespace WindowsFormsApp6 { static class Program { /// /// Der Haupteinstiegspunkt für die Anwendung. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } *here } 我理解,我是否必须在静态void下添加以下内容? (在这儿): using (PowerShell PowerShellInstance = PowerShell.Create()) { } […]

Visual Studio设计器中的抽象通用UserControlinheritance

在我的一个项目中,我正在使用抽象的UserControl。 为了能够在Visual Studio中设计此控件,我使用了本答案中提出的代码。 现在我想使用另一个抽象的UserControl,它也是通用的。 但如果我这样做 [TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<MyBaseControl, UserControl>))] 我收到了编译器错误 CS0416:属性参数不能使用类型参数 删除类型参数显然也无法编译。 我无法从非generics基类派生MyBaseControl,因为它已经从通用基类派生,所以我尝试使用接口进行装饰并使用它如下: [TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider))] 这确实编译但是当我打开设计视图时,我的控件不会被渲染,而是我得到了错误 提供的generics参数的数量不等于generics类型定义的arity。 有办法解决这个问题吗?