向IContainer发出添加组件的问题

时间:2015-01-27 16:12:44

标签: c# .net

我有一个名为容器的IContainer,我正在尝试使用add方法向其添加组件。添加时我收到此错误

  

错误1最佳重载方法匹配   “System.ComponentModel.IContainer.Add(System.ComponentModel.IComponent,   字符串)'有一些无效   参数C:\ Users \ Dan \ Source \ Workspaces \ Bio-Catalysts   repack \ Biocats_Repack \ itas.s200.biocats.business \ SOP \ SOPOrderLineVwItems.cs 19 13 itas.s200.biocats.business

下面是代码:

namespace itas.S200.Biocats.Business.SOP
{
    using System;
    using System.Collections;
    using System.ComponentModel;
    using Sage.Common.Data;
    using Sage.ObjectStore;


    public class SOPOrderLineVwItems : PersistentSOPOrderLineVwItems
    {

        public SOPOrderLineVwItems()
        {
        }

        public SOPOrderLineVwItems(System.ComponentModel.IContainer container)
        {
            container.Add(this, null);
        }

        //public SOPOrderLineVwItems(System.Data.IDataReader reader) : 
        //        base(reader) 
        //{
        //}

        [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public new virtual SOPOrderLineVwItem this[int index]
        {
            get
            {
                return ((SOPOrderLineVwItem)(base[index]));
            }
            set
            {
                base[index] = value;
            }
        }

        [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public override Sage.ObjectStore.PersistentObject Owner
        {
            get
            {
                if ((this.Query.Owner == null))
                {
                    this.Query.Owner = new SOPOrderLineVwItem();
                }
                return this.Query.Owner;
            }
        }

        [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public new virtual SOPOrderLineVwItem First
        {
            get
            {
                return ((SOPOrderLineVwItem)(base.First));
            }
        }
    }
}

如果需要,可以提供更多代码/信息

由于

1 个答案:

答案 0 :(得分:0)

public class SOPOrderLineVwItems : PersistentSOPOrderLineVwItems, IComponent
  

IComponent Add()将IComponent作为参数。   Add

因为你这样做了

container.Add(this, null);

您需要this SOPOrderLineVwItemsIComponent