Alexander Ryan Baggett
Alexander Ryan Baggett

Reputation: 2397

Winforms User Control MissingMethodException

So essentially, I have a custom user control called ExcelDisplay. I try to drag it over in visual studio from the toolbox into my webform in the same project and I get a missing method exception. At one time the constructor was parameterized, but I changed it after deciding it was a bad design idea.

It looks like it is saying the constructor is missing, but its obviously there.

My winform to house the control is empty with the exception of the autogenerated code visual studio puts there.

The code for my ExcelDisplay's constructor looks like this.

    namespace STS_Console.UserControls
    {
        public partial class ExcelDisplay : UserControl
        {

            public ExcelDisplay()
            {
                InitializeComponent();

                DataDisplay.Columns[0].HeaderText = "Data";
                //debug
                string x = DataDisplay.Columns[0].GetType().ToString();
                x.ToString();
            }

The error message is this. error message

So that error occurs when do I drag and drop in the designer like this  Drag and drop

Anyway so that is my problem. I am not sure what is causing it or how to fix it. I would be glad to post additional code upon request.

Upvotes: 1

Views: 1415

Answers (3)

joy chen
joy chen

Reputation: 1

Maybe delete the .usercontrol in namespace will work

Upvotes: 0

FlappySocks
FlappySocks

Reputation: 3880

Rebuild Solution fixed it for me, although if your making regular changes to your user control, you should put them into a separate project.

My particular problem, was a user control, within a user control.

Upvotes: 1

nvoigt
nvoigt

Reputation: 77304

You should put your user controls in a class library of their own. For the designer to work, it needs a compiled version of your user control. If you cannot compile your user control before you compile your form, you will get into all kinds of trouble.

Upvotes: 1

Related Questions