智能标签(又名 ActionList)在 Visual Studio 中崩溃
将 VS2010(或 VS2008)中的智能标签添加到我的控件中会使 VS 崩溃。
以下设计器用于操作列表:
internal class DataEditorDesigner : ComponentDesigner {
[...]
public override DesignerActionListCollection ActionLists {
get {
var lists = new DesignerActionListCollection();
lists.AddRange(base.ActionLists);
lists.Add(new DataEditorActionList(Component));
return lists;
}
}
}
internal class DataEditorActionList : DesignerActionList {
public DataEditorActionList(IComponent component) : base(component) {}
public override DesignerActionItemCollection GetSortedActionItems() {
var items = new DesignerActionItemCollection();
items.Add(new DesignerActionPropertyItem("DataSource", "Data Source:", "Data"));
items.Add(new DesignerActionMethodItem(this, "AddControl", "Add column..."));
return items;
}
private void AddControl() {
System.Windows.Forms.MessageBox.Show("dpa");
}
}
DataSource 属性声明如下:
[AttributeProvider(typeof (IListSource))]
[DefaultValue(null)]
public object DataSource {
[...]
关于如何调试它有什么想法吗?
Adding smart tags in VS2010 (or VS2008 for that matter) to my control makes VS crash.
The following designer is used for the action list:
internal class DataEditorDesigner : ComponentDesigner {
[...]
public override DesignerActionListCollection ActionLists {
get {
var lists = new DesignerActionListCollection();
lists.AddRange(base.ActionLists);
lists.Add(new DataEditorActionList(Component));
return lists;
}
}
}
internal class DataEditorActionList : DesignerActionList {
public DataEditorActionList(IComponent component) : base(component) {}
public override DesignerActionItemCollection GetSortedActionItems() {
var items = new DesignerActionItemCollection();
items.Add(new DesignerActionPropertyItem("DataSource", "Data Source:", "Data"));
items.Add(new DesignerActionMethodItem(this, "AddControl", "Add column..."));
return items;
}
private void AddControl() {
System.Windows.Forms.MessageBox.Show("dpa");
}
}
The DataSource property is declared as such:
[AttributeProvider(typeof (IListSource))]
[DefaultValue(null)]
public object DataSource {
[...]
Any ideas on how to debug it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。有必要将包装器属性添加到 DesignerActionList 类中,这是从其中读取它们的位置,而不是从实际组件中读取它们。另外,有必要编写这样的代码:
然后使用它:
等等其他属性。
I've found the solution. It's necessary to add wrapper properties to DesignerActionList classes, that's where they're read from, not from the actual component. Also, it's necessary to write such code:
and then use it:
and so on for other properties.