Greetings,
I've an add-in that loads fine but shown as 'dimmed' or 'disabled' in
Tools menu. Here is the OnConnect function implementation:
Try
_applicationObject = CType(application, EnvDTE80.DTE2)
_addInInstance = CType(addInInst, EnvDTE.AddIn)
If connectMode = ext_ConnectMode.ext_cm_UISetup Then
Dim objAddIn As AddIn = CType(addInInst, AddIn)
Dim CommandObj As Command
Dim objCommandBar As CommandBar
ClearExistingCommands()
objCommandBar =
CType(_applicationObject.Commands.AddCommandBar("CommenterMacros",
vsCommandBarType.vsCommandBarTypeMenu,
_applicationObject.CommandBars.Item("Tools")),
Microsoft.VisualStudio.CommandBars.CommandBar)
CommandObj =
_applicationObject.Commands.AddNamedCommand(objAddIn,
"InsertSeeAlsoTag", "InsertSeeAlsoTag", "TODO: Enter your command
description", True, 59, Nothing, 1 + 2)
CommandObj.AddControl(objCommandBar)
End If
Catch ex As Exception
MsgBox(ex.StackTrace, MsgBoxStyle.Information, "Add-in Error")
End Try
'***************************
Where the ClearExistingCommands function as follows:
Private Sub ClearExistingCommands()
Try
For Each cmd As CommandBarControl In
CType(_applicationObject.CommandBars.Item("Tools"), CommandBar).Controls
If cmd.Caption = "CommenterMacros" OrElse cmd.Caption
= "CommentMacros" Then
cmd.Delete()
End If
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Add-in Error")
End Try
End Sub
'**********************************************
When i debug the code it fires an exception on the line:
CommandObj = _applicationObject.Commands.AddNamedCommand(objAddIn,
"InsertSeeAlsoTag", "InsertSeeAlsoTag", "TODO: Enter your command
description", True, 59, Nothing, 1 + 2)
"A Command with that name already exists.". Am i missing something??