5

While learning on working with the ribbon UI in my outlook addin(VS2010), I deleted and added ribbon items several times. Since yesterday, when I am adding a ribbon item, some of the autogenerated code is not compiling.

partial class ThisRibbonCollection
{
    internal MyRibbon MyRibbon
    {
        get { return this.GetRibbon<MyRibbon>(); }
    }
}

The error thrown is

'MyAddin.ThisRibbonCollection' does not contain a definition for 'GetRibbon' and no extension method 'GetRibbon' accepting a first argument of type 'MyAddin.ThisRibbonCollection' could be found (are you missing a using directive or an assembly reference?)

So, to get rid of this, I commented out the code block and it compiled. Now, the issue I am facing is that I cannot access the ribbon via the Globals object as mentioned here.Access Ribbons at runtime . I tried "grepping" the entire solution for ribbon specific code and deleted them and tried adding a ribbon item but the issue persists.

I can access my addin from the controls on my ribbon but the reverse is not happening.

Abhi
  • 261
  • 1
  • 3
  • 12
  • If I create a new addin project and add a ribbon item, the same block of code compiles without any issue. I think my repetitive deleting and adding of ribbon item messed up my project in some way. This code is in the myRibbon.Designer.cs file. – Abhi Aug 02 '12 at 14:05
  • 1
    Run a compare/diff tool against the files of the working and broken projects and look for any differences. That will give you a clue what broke. – iCollect.it Ltd Aug 02 '12 at 14:09
  • 1
    anybody looking for a simple solution to this problem visit [this SO page](http://stackoverflow.com/questions/17105764/an-excel-ribbon-via-vsto-solution-explorer-folder-structure-vs-path-in-code) –  Jun 14 '13 at 11:17

2 Answers2

14

That error may be is because you create the ribbon in a folder, creating a new namespace.

Easy solution: delete the namespace name.

Tavo
  • 521
  • 5
  • 4
  • 1
    Folder name part should be deleted from the namespaces in two files MyRibbon and MyRibbon.Designer.cs – Makatun Apr 03 '15 at 20:29
  • Thanks. this help me – MSH Dec 18 '16 at 14:23
  • To expand on this answer: you may have to delete the namespace name in two places: in the MyRibbon.Designer.cs and in the MyRibbon.cs classes. The MyRibbon.cs class is accessible by pressing F7 in VS2019 or by "View code" from context menu of the file in Solution Explorer view. – Colm Bhandal May 02 '19 at 14:22
-2

Running a diff with another similar project helped me fix this issue.

Abhi
  • 261
  • 1
  • 3
  • 12
  • 1
    You could have let us known what the solution was! – Asherah Apr 02 '14 at 02:14
  • 1
    This answer is unhelpful and shouldn't be accpeted. The other answer of Tavo seems to be helping more users. Suggestion to the OP: delete this answer and accept Tavo's answer. It will improve the SO community. – Colm Bhandal May 02 '19 at 14:18