ArcMap crashes with add-in, but not when started from Visual Studio 2012

1357
1
05-12-2014 12:57 AM
SteffanVoss
New Contributor II
I am building an add-in for a while. It is open source and the code is here: https://mcda4arcmap.codeplex.com/SourceControl/latest.

The problem:
ArcMap (latest version) crashes on start up when the add-in is installed.
According to the log file sometimes when the extensions are initialized, which makes sense.

The interesting part is that it works very well when I start it via Visual Studio 2012. At some point in time (2 months ago?) it also worked without Visual Studio 2012, but I developed and never tested it without and therefore I have no idea what change causes this behavior.

Another interesting observation is that I can install the add-in for the first time and use a small part of the functionality (every other will crash ArcMap) without a problem. When I restart ArcMap, ArcMap will crash again.

The last observation is that I can start it from Visual Studio 2013. In lets say 1 out of 10 times Visual Studio 2013 will crash and ArcMap starts or ArcMap.exe cannot be started and Visual Studio 2013 does not crash.

I have two external dlls included and target version is 4.5 (4.0 will also crash, I tried it).

The only option I see is to remove features and try until I find the evil method call or whatever.

Do I have a chace to debug the ArcMap extension initialization?
It would be beneficial to know what ArcMap does with add-ins on start up, e.g. is the startup method of my extension called? What checks are performed?
0 Kudos
1 Reply
RichardWatson
Frequent Contributor
When it crashes, a crash dump should be generated:

http://support.esri.com/em/knowledgebase/techarticles/detail/40370

You can open the crash dump in Visual Studio and see where it crashed.  Hopefully, that gives you some insights into the problem.

In terms of debugging:
1) You can launch the ArcMap process from the debugger
2) You can run ArcMap and then attach to process
3) You can launch the debugger from your code (see System.Diagnostics.Debugger.Launch and Break)
4) You can debug the crash dump
5) You can use print statements (I use the Debug View utility) or logging

Make sure that you configure the debugger to use the ESRI symbol server.

Finally, if Visual Studio is being less than helpful then use WinDbg (free from Microsoft).
0 Kudos