I'm trying to implement a custom tool for an add-in. I inserted the following snippet, which works fine:
Dim UIDCls As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass()
' id property of menu from Config.esriaddinx document
UIDCls.Value = "esriArcMapUI.ZoomInTool"
Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem = TryCast(document.CommandBars.Find(UIDCls), ESRI.ArcGIS.Framework.ICommandItem)
If commandItem Is Nothing Then
Exit Sub
End If
My.ArcMap.Application.CurrentTool = commandItem
I then added a custom tool:
Add New Item>ArcGis>Extending ArcObjects>Base Tool. I called it (default) Tool1.vb. It created a module allowing me to add code for mouse events, along with some COM GUIDs.
When I try to replace the UIDCls value above (esriArcMapUI.ZoomInTool) to refer to my custom tool, Arcmap will crash.
My project is called VBNET_Test, so I've tried referring to my tool as VBNET_Test.Tool1, VBNET_Test_Tool1; also tried giving the tool a MyBase.m_name and referring to that as Tool1_[m_name]. Everything I do causes ArcMap to crash. The only way I can get ArcMap to continue, (to the Exit Sub line, because the tool's not recognized - CommandItem=nothing) is by adding the classID in the tool module ("{513f6529-78cf-4913-a86d-058985bbf4ed}").
My tool is not on a toolbar/command bar - but I've read others' experiences stating that this is not necessary. I don't want it on a toolbar. In my VBA project I had to have the tool on a toolbar.
Potentially related is my selection of disabling Com interop in the main project properties. If I enable it I get an error and the code won't compile. The error states:
Error 1 Cannot register assembly "C:\Users\Computer\Documents\Visual Studio 2008\Projects\VBNet_Test\VBNet_Test\bin\Debug\VBNet_Test.dll". Could not load file or assembly 'ESRI.ArcGIS.Desktop.AddIns, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86' or one of its dependencies. The system cannot find the file specified. VBNet_Test
Any help would be greatly appreciated. I'm trying to migrate a huge VBA project over to VB.net- some things seem really easy but this has me stumped.