Hi folks
i need to add some functionality to ArcMap's File-Menu. I'm using the code listet below to create the add-in and adding the button to the menu... well, clicking the menu 'file' causes ArcMap to crash. So obviously, there has to be an error.
any ideas?
esriaddinx:
<AddIn language="CLR" library="GeoServerData.dll" namespace="GeoServerData">
<ArcMap>
<Commands>
<Button id="Stadt_Zürich_uidsample_Button1" class="Button1" message="Add-in command generated by Visual Studio project wizard." caption="My Button" tip="Add-in command tooltip." category="Add-In Controls" image="Images\Button1.png" />
</Commands>
<Extensions>
<Extension id="Stadt_Zürich_uidsample_Extension1" class="Extension1" productName="UIDSample" showInExtensionDialog="true" autoLoad="true" />
</Extensions>
</ArcMap>
</AddIn>
class Extension (inherits from ESRI.ArcGIS.Desktop.AddIns.Extension)
Protected Overrides Function OnSetState(ByVal state As ESRI.ArcGIS.Desktop.AddIns.ExtensionState) As Boolean
If state = esriExtensionState.esriESEnabled Then
' Add OnNewDocument event handler.
m_dNewDocEvent = New ESRI.ArcGIS.ArcMapUI.IDocumentEvents_NewDocumentEventHandler(AddressOf AddCommandToMenu)
AddHandler CType(m_MxDoc, ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event).NewDocument, m_dNewDocEvent
' Add OnOpenDocument event handler.
m_dOpenDocEvent = New ESRI.ArcGIS.ArcMapUI.IDocumentEvents_OpenDocumentEventHandler(AddressOf AddCommandToMenu)
AddHandler CType(m_MxDoc, ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event).OpenDocument, m_dOpenDocEvent
End If
Return MyBase.OnSetState(state)
End Function
Public Sub AddCommandToMenu()
Try
Dim pUID As New UID With {.Value = "{56599DD3-E464-11D1-9496-080009EEBECB}"}
Dim pCmdItem As ICommandBar
pCmdItem = application.Document.CommandBars.Find(pUID)
Dim btnuid As New UID With {.Value = My.ThisAddIn.IDs.Button1}
pCmdItem.Add(btnuid,0)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
class Button1:
Public Sub New()
application = CType(Hook, IApplication)
End Sub
Protected Overrides Sub OnClick()
MsgBox("HALLO!")
End Sub
any help will be greatly appreciated!
best regards