Bases classes & Forms

class A : System...Forms.Form
{}

class B : A  //designer for class B -O'K
{}

class C : B  //designer for class C - ERROR

{}


Why does the designer screen of VS show me a big X instead of the form and say:

"The service System.Windows.Forms.Design.IEventHandlerService already exists in the service container.  Parameter name: serviceType."

It seems/appears I'm duplicating something.   If I state "class C : A" everything is O'k but the DataSet I need is in class B. 

Steve



Answer this question

Bases classes & Forms

  • Uminder

    hi, your solution did not work.

    heres my code (and I am still getting the error)

    private void FrmBaseDataForm_Load(object sender, EventArgs e) {

    // Check if Design Mode : Cause Error

    if (!DesignMode)

    {

    DoBindControls();

    }

    }



  • rthiney

    You need in your load events of all your forms do a wrapper around the code

    if not designmode then
    'your code
    end if

    You see when you inherit a form in another form, it runs the load in the base form and if the load in the base form has some operation that fails then you get error on the form inheriting the base form.

    Hope this helps.

  • Cimares

    I'm getting the same thing.

    I would add that I used VS'es 'visual inheritance' mechanism to derive B from A and then C from B.  Also I left the signature for constructors B() and C() alone, they are the standard constructors generated by VS.  I did it as 'VS friendly' as I could.

    I can see the design view for B.  At first I could see the design view for C, but then I closed VS and after reopening I can't see it any more.  However the program compiles and runs just fine.

  • Bases classes & Forms