Partial method implementation gives error "no defining declaration found for implementing declaration of partial method..."

8.5k Views Asked by At

I'm writing a Winforms project that needs a settings form. For that settings form, I want to have two modes, a basic and an advanced. I've written the code to make it change between these two, and to save time, I want to have the InitializeComponent() method just call the same method that gets called to switch to the basic mode. I created a partial method like this:

        partial void InitializeComponent()
        {
            BasicSettingsButton_Click(new object(), new EventArgs());
        }

inside my partial class in my program file (not the one the Windows form designer generates), and changed the one in the Window form designer generated code to:

        partial void InitializeComponent();
        //{
        //...
        //}

which I thought was proper syntax for the signature, with the implementing definition as above.

However, when I try to build the code, it tells me it has "no defining declaration found for implementing declaration of partial method InitializeComponent()" and points me to the first code sample I have.

I've checked names, even copying and pasting corresponding names to ensure they're the same, but I still can't get it to run. This is the only error in my code stopping me from building and running. Any ideas?

0

There are 0 best solutions below