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

4368
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
JeffreyHamblin
New Contributor III
I haven't run into any of the problems you describe, although I am using Visual Studio C# 2008 Express. It has worked seemlessly for me and is easy as billed. I understand your frustration.

My best guess is that either the SDK installer did not properly configure the SDK for use with your VS installation, or you are doing something unusual when creating the project.

I am working on a tutorial for VBA to Add-in conversions. It is for C# instead of VB.NET, but you might want to look at Parts 3 and 4 to see if you're doing anything differently.

http://gis.qtools.com/blog/tutorials/vba-to-c-add-in/part-3-setting-up-visual-studio/

Unless someone else posts a better solution, I think the next step would be to uninstall the ArcObjects SDK, then reinstall. If that doesn't work, uninstall/reinstall both the SDK and Visual Studio.

-Jeff
0 Kudos
elisapuccioni
New Contributor II
Hi again,
I've tried all Jeff's suggestions but still have the some hollow red circle as Dale. In other Visual Studio forums I've found that the error we get seems to be generated by the lack of a .pdb file in the Debug folder, but actually I have this file in my folder. Probably the only thing to do is trying to reinstall the SDK again.
Dale, if you find a solution, please share it!
Thanks everybody,
Elisa
0 Kudos
DaleBridgford
New Contributor III
Thanks Jeff.  I will have a look at your tutorial and see if that sparks any ideas.  This morning, I installed SP1 for ArcMap and the ArcObjects SDK.  Same problems, new versions.  BTW, I am using the Express versions of both VB and C# (2008).

I can follow VB and have looked at C# and get the basic gist of the syntax, but I don't know if I want to expend the time to try and translate the VB to C#.  Is the help documentation and intellisense better for C#?

Thanks,

Dale
0 Kudos
JeffreyHamblin
New Contributor III
Dale,

One other quick thing to check. If you build your test project that displays a message box, then close Visual Studio and launch ArcMap 10 alone, does your button display the message box?

I'm just wondering if some debugger settings in VS are getting in the way.

-Jeff
0 Kudos
AnnaForrest
New Contributor II
I haven't used add-ins hardly at all, but I did have trouble getting ESRI stuff to run my commands right when they were in a namespace. Can you try and remove the namespacing at least to test?

In my case I managed to retain the namespacing by decorating my classes with <ProgId("ProjectName.CommandName")>
0 Kudos
JeffreyHamblin
New Contributor III
Well, if it makes you all feel any better, I just started having the same problem with one of my projects! Buttons gray out when clicked and nothing happens... It had been working fine for over a month. I didn't make any changes to it.   😞

I'm using Visual Studio C# 2008 Express.

Doesn't matter whether I'm debugging or running ArcMap outside a debug session.

But, a different project still works, both debugging and not. So it's not a global problem.

I tried deleting the Add-In manually from:
C:\Users\<username>\Documents\ArcGIS\AddIns\Desktop10.0

And deleting the assembly cache from:
\Users\<username>\AppData\Local\ESRI\Desktop10.0\AssemblyCache\
(note: you have to set folder options to display hidden protected operating system files)

I even tried code-signing the Add-In.

Didn't fix it... grrrr. I have a deadline tomorrow and this is not good.

-Jeff
0 Kudos
DaleBridgford
New Contributor III
Jeff,

Oddly, I just finally got my code to crash.  Based on one of the examples I had seen in the past, I put a Namespace - End Namespace around my code.  I built a "Hello World" button and it successfully ran.  I noted that it did not put Namespace in any of the wizard generated code, so I took the reference out.  Upon recompiling, as Arc launched, the Breakpoint went hollow, but when I pressed the button on the toolbar, it fired the code and went to the refilled in breakpoint.  It immediately crashed on the second line of my code, but its the first sign of progress I have had in over a month of dinking around with this stuff.

Does your code have use Namespace, or is that not an issue in C#?  Hope you can figure it out.

Dale
0 Kudos
NeilClemmons
Regular Contributor III
I haven't had need to create an add-in yet but just a quick question.  When you compile your add-in, is Visual Studio creating the project output in one location (i.e. the Debug directory under your project directory) and then the output is copied to a location where ArcGIS expects to find it (i.e. the Add-ins directory)?  If so, have you tried modifying your Visual Studio project properties to create the project output directly in the ArcGIS Add-ins directory?  One thing that could be happening is Visual Studio is creating registry entries for your classes each time the project is compiled and then ArcGIS is doing the same thing when it finds your add-in assemblies.  This causes confusion because the system has entries in the registry for the same classes in two separate locations.  If this is indeed what is happening, then the only way I know to rectify the situation is to delete all of the class entries in the registry, which can be tricky to say the least.
0 Kudos
JeffreyHamblin
New Contributor III
Thanks for the replies, Neil and Dale,

One thing I found is that I can install an older version of the same Add-In from its .esriAddIn file -- and it works fine. And it has the same AddInID.

So something is getting munged on a per Add-In basis.

The compiled Add-In does end up in three locations: debug, release, and the ESRI Add-Ins folder. So I will see if I can find any duplicate registry entries...

-Jeff
0 Kudos
AlexanderGray
Occasional Contributor III
I have never used visual studio express but in visual studio, under tools, there is an attach to process option.  If you start ArcMap, from the start menu, in vs, you can attach to the arcmap process.  As long as the dll loaded (in addins folder) is compiled in debug mode and the debug metadata is there (.pdb), you should be able to at least debug the code.  It is possible your code is running, failing, not handling the exceptions and it looks like the code didn't run at all.  Could also explain why some code runs and some other doesn't.
0 Kudos