Add-in; Failure to get code to execute when toolbar button pressed

4243
25
11-22-2010 06:10 AM
DaleBridgford
New Contributor III
Hi,

I had written several VBA routines up through 9.3 and have since upgraded to 10.  Since VBA will be a thing of the past in the next version, I downloaded and installed VB Express 2008 and successfully (I think) migrated the VBA to VB.Net 2008.  I saved out each of the routines to their respective *.vb files and ran the Add-In wizard for a new project, adding each routine as a button added to a toolbar.

Everything compiles and I get my toolbar to show up in ArcMap, but when I press any of the buttons, they grey out and nothing executes.  Similarly, the breakpoints I have inserted go hollow with a yellow triangle and when I hover over the breakpoint, it states that "The breakpoint will not currently be hit.  No symbols have been loaded for this document."

I think that somehow I am missing the magic of how to tie the XML stuff to the VB.Net code.  Is there any VB code that links the code back to the XML so it functions? 

Any insight is greatly appreciated.

Thanks,

Dale Bridgford
0 Kudos
25 Replies
DaleBridgford
New Contributor III
To provide a bit more background, I am enclosing a portion of the code.  This is typical of what I have cludged together from various posts.  All variations that I have tried are equally inoperative.

Again, any insight as to where I have gone astray would be greatly appreciated.

Thanks,
Dale Bridgford

Imports ESRI.ArcGIS.Geometry


Namespace ERMDTools

    Public Class btnAddHyperlink
        Inherits ESRI.ArcGIS.Desktop.AddIns.Button
        Public Sub New()

        End Sub

        Protected Overrides Sub OnClick()
            Dim pFeature As IFeature, pLayer As ILayer
            Dim pMap As IMap
            Dim pSRE As SpatialReferenceEnvironment
            Dim pQF As IQueryFilter
            Dim pMSR As ISpatialReference
            Dim pGeoDataset As IGeoDataset
            Dim pMxDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument
            pMxDoc = Nothing
            pMxDoc = m_App.Document
            pMap = pMxDoc.FocusMap
            pMSR = pMap.SpatialReference 
0 Kudos
DaleBridgford
New Contributor III
To provide a bit more detail to my question, all of the routines I had written, check for the existence of a field in the attribute table, create the field if not present, and populates the field.

In reading about add-ins, there were some limitations, but I didn't quite catch whether working on the table structure would be within those limitations.
0 Kudos
elisapuccioni
New Contributor II
Hi Dale,

I'm having exactly the same problem. did you find a solution? Any help will be really appreciated!

Thanks,
Elisa
0 Kudos
DaleBridgford
New Contributor III
Elisa,

Sorry, but to this point, I have had no responses in either place I have posted this question.  If there is additional information anyone needs on this, please let me know.  The add-in concept seems to make for a clean way to distribute functionality without having to register .dll's or the like.

Thanks,

Dale
0 Kudos
JeffreyHamblin
New Contributor III
Rather than immediately trying to implement your VBA code conversion, have you tried just getting a simple message box "Hello World" to display from the OnClick() event? That way you check if the basic Add-In framework is working correctly before incorporating any actual ArcObjects code. The wizard should be handling all the XML and boilerplate code.

-Jeff
0 Kudos
DaleBridgford
New Contributor III
Thanks for the suggestion, Jeff.  I will attempt to see if that works now.
0 Kudos
DaleBridgford
New Contributor III
Thanks for the suggestion, Jeff.  I will attempt to see if that works now.


Well, I still seem to be unable to have the button invoke my code.  From my original code post above, I commented all of the code in the Protected Overrides Sub and just threw in a messagebox statement. 

Below is the XML for the Add-In, if that might give any insight.
Thanks for any suggestions.

Dale


<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>ERMDTools</Name>
  <AddInID>{eb6ba448-f56d-4ac4-9ba8-1ae452fb5519}</AddInID>
  <Description>Conversion of my VBA tools to add coordinates to tables and such.</Description>
  <Version>1.0</Version>
  <Image>Images\ERMDTools.png</Image>
  <Author>Dale R. Bridgford</Author>
  <Company>SOM</Company>
  <Date>12/13/2010</Date>
  <Targets>
    <Target name="Desktop" version="10.0" />
  </Targets>
  <AddIn language="CLR" library="ERMDTools.dll" namespace="ERMDTools">
    <ArcMap>
      <Commands>
        <Button id="SOM_ERMDTools_AddPolygonCentroid" class="btnAddPolygonCentroid" message="Adds the X and Y coordinates of each polygon's centroid (center of mass) to the attribute table" caption="Polygon Centroid XY" category="Bridgford Tools" image="Images\AddPolygonCentroid.png" tip="Adds the latitude and longitude of the polygon's centroids"></Button>
        <Button id="SOM_ERMDTools_AddPolyLineCentroid" class="btnAddPolyLineCentroid" message="Adds the X and Y coordinates of each polyline's centroid (center of mass) to the attribute table." caption="Polyline Centroid XY" category="Bridgford Tools" image="Images\AddPolyLineCentroid.png" tip="Adds the latitude and longitude of the polyline's centroid."></Button>
        <Button id="SOM_ERMDTools_AddXY" class="btnAddXY" message="Adds the XY coordinates of the point to the attribute table." caption="Point XY" category="Add-In Controls" tip="Adds XYs to the Attribute Table" image="Images\AddXY.png"></Button>
        <Button id="SOM_ERMDTools_AddXYZ" class="btnAddXYZ" message="Adds XYZ of DataFrame and XY of feature" category="ERMDTools" caption="Add XYZ and XY" tip="Populates attribute table with XYZ of dataframe and xy of feature so you get two sets of coordinates for the price of one." image="Images\AddXYZ.png"></Button>
        <Button id="SOM_ERMDTools_AddHyperlink" class="btnAddHyperlink" message="Creates Hyperlink to ERMD's WDS Webpage." caption="Add Hyperlink" category="Add-In Controls" tip="Generates a Hyperlink based upon data in attribute tables and places hyperlink in attribute table" image="Images\AddHyperlink.png"></Button>
      </Commands>
      <Toolbars>
         <Toolbar id="SOM_ERMDTools_ERMD_Tools" caption="ERMD Tools" showInitially="true">
          <Items>
            <Button refID="SOM_ERMDTools_AddHyperlink" />
            <Button refID="SOM_ERMDTools_AddXY" separator="true" />
            <Button refID="SOM_ERMDTools_AddXYZ" separator="true" />
            <Button refID="SOM_ERMDTools_AddPolyLineCentroid" separator="true" />
            <Button refID="SOM_ERMDTools_AddPolygonCentroid" separator="true" />
          </Items>
        </Toolbar>
      </Toolbars>
    </ArcMap>
  </AddIn>
</ESRI.Configuration>
0 Kudos
JeffreyHamblin
New Contributor III
I don't see anything obviously wrong in your Config.esriaddinx code.

There have been other posts here indicating some problems relating to project builds in Visual Studio not updating the Add-in. I have not experienced that problem, but it might be worth a shot for you to clear the Add-in.

Delete the folder with the GUID name that is the same as the AddInID in
XP:
c:\Documents and Settings\<username>\My Documents\ArcGIS\AddIns\Desktop10.0
Win7/Vista:
C:\Users\<username>\Documents\ArcGIS\AddIns\Desktop10.0

Do a Rebuild solution and the start debugging to test the Add-In.

If that doesn't fix it, try starting a new test Add-In that only has a single button and toolbar, and just the message box in the button click. So let the wizard create all the code except the one line for the message box.

-Jeff
0 Kudos
DaleBridgford
New Contributor III

If that doesn't fix it, try starting a new test Add-In that only has a single button and toolbar, and just the message box in the button click. So let the wizard create all the code except the one line for the message box.

-Jeff


Thanks for the suggestions.  I ended up deleting everything as suggested and recompiled to try again.  It continued to give me a hollow red circle with a yellow triangle at breakpoints I inserted into the code and when I hover over the breakpoint, it states that "The breakpoint will not currently be hit. No symbols have been loaded for this document."  This has been consistent throughout this project.

I then created a new project consisting of one button and no tool bar.

The entire code in Button1:
Public Class Button1
  Inherits ESRI.ArcGIS.Desktop.AddIns.Button

  Public Sub New()

  End Sub

  Protected Overrides Sub OnClick()
    '
    '  TODO: Sample code showing how to access button host
    '
    My.ArcMap.Application.CurrentTool = Nothing
  End Sub

  Protected Overrides Sub OnUpdate()
    Enabled = My.ArcMap.Application IsNot Nothing
  End Sub
End Class


Where the TODO is in the commented area is where I placed the messagebox code (after I uncommented it).  Compiling and running again gave me the hollow red circle with the yellow exclamation mark.

This is frustrating since the way the add-in has been presented makes it an appealing way to distribute functionality.

Thanks,

Dale
0 Kudos