Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
       {

           myUserControl1 = new MyUserControl1();

           myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "My Task Pane");

           myCustomTaskPane.Visible = true;


MyUserControl1 does not contain a definition for 'CustomTaskPanes' and no accessible extension method 'CustomTaskPanes' accepting a first argument of type 'MyUserContrl1' could be found.

Any thoughts?

What I have tried:

I've tried using global over "this" and tried to troubleshoot using suggested edits but they do not accomplish the needed task.
Posted
Updated 30-Nov-20 5:48am
Comments
[no name] 30-Nov-20 11:50am    
Your "code" says there is an "object" called "CustomTaskPanes" somewhere but the compiler can't find it. Neither can we given what you've shown. It usually happens when one copies code they don't understand.

1 solution

In C#, this refers to the current instance of the current class: so in a Form, this.Text refers to the form Title bar line. In a Button, this.Click refers to the Click handler for that button and no other.

So unless the current class includes a definition of a variable or sub class called CustomTaskPanes you cannot access it via this.

Start by looking for where CustomTaskPanes is defined: if it's a variable, is it defined at class level or inside a method (scope rules will apply in the latter case)? Is it a separate class entirely - in which case is the Add method declared as static?

We can't tell - we have no access to your code other than exactly what you type here!
 
Share this answer
 
Comments
Member 14962410 30-Nov-20 12:08pm    
Thank you both. I am re-reviewing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900